From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2F7CEB64D9 for ; Thu, 15 Jun 2023 10:17:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245620AbjFOKR0 (ORCPT ); Thu, 15 Jun 2023 06:17:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236407AbjFOKRW (ORCPT ); Thu, 15 Jun 2023 06:17:22 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F65AC for ; Thu, 15 Jun 2023 03:17:20 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-4f642a24568so10277886e87.2 for ; Thu, 15 Jun 2023 03:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686824239; x=1689416239; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=2VrkMso6gSzSG+XS+vDDk4F97yS4RBvowjqFaI7E2vg=; b=lFCG8OVwrXZfc2r+DuTaZta5qrr5aKjP9qp3I7Af60jPV5Zs8aGyAg23iIIOtMX6em 1oMsb6LnatM7muokbqrSQfJolYKeCFgrOCO0lgTzB7tgZftHc7Pk4Ef3LcG+vOtY8tVT jsBvY0Xxm/BeshihIC4/3VK5jtg6XOzZZY92SBlWi/FYMSgBVXZ+Xr/s7/HORWFL2oE9 hZj2wQElM+PFbhLC+vk5s90Sj8EaGIRYhwgxn5sI+pES9xlg0WTKG3rcIvuyTTdBdh5w cS4sUzSH0klZ0ytYF5RByUn/HU6gH8+YQToyJI4r0wPO+n1s6mJtllsy1Yd4lV5PYLjq qlaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686824239; x=1689416239; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2VrkMso6gSzSG+XS+vDDk4F97yS4RBvowjqFaI7E2vg=; b=VjOZrFh7ELrG3tRI3dQdleAegrQz0hNfXXzLE6SisIZ/d4Ug3D36aJfEggE6Rx2fcp +K/SQ1r/gDwRK0+qhchpu2t+ILGBSQ36lZ9aUlVeKS2T/CYxzboKEgB6decL90+nh4ga xJXr6e08jPOZpBBBR+fNvMDf4m2SMlwao84i3wZoS1+KLwEXk/Qm2LF4mV9LoNVSkzIM qWDFXzDYq4tPPKGR0d8sTmGzykMUyL6v66SleKJZvkFGZvewJDGaWhpzSB89jtMGb8pL UMYbnQI1yBOvfqW/vtOBuxYr8Mw9XlowJfZSfvPvH+6RM2D+/4vdwk0vPSDTqvEexmOt 2RUA== X-Gm-Message-State: AC+VfDxRm0B/Aq9om8an/kRhdLeEchhplifxn7wAuKqrDRTOvg1sDfJA 9EdLIgA3YnyMSw/a1xDVWapi8Q== X-Google-Smtp-Source: ACHHUZ5lzsyAA1o0LiPPDL3xlSM2j3ov9rzuDZ//SwNmj5QBrOYfKbAmu+BpH8v0thDXRV9AvtQznw== X-Received: by 2002:a19:da12:0:b0:4f7:4098:9905 with SMTP id r18-20020a19da12000000b004f740989905mr8220883lfg.65.1686824238738; Thu, 15 Jun 2023 03:17:18 -0700 (PDT) Received: from ?IPV6:2001:14ba:a0db:1f00::8a5? (dzdqv0yyyyyyyyyyybcwt-3.rev.dnainternet.fi. [2001:14ba:a0db:1f00::8a5]) by smtp.gmail.com with ESMTPSA id y12-20020a19750c000000b004ef92c6e645sm2100795lfe.263.2023.06.15.03.17.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 03:17:18 -0700 (PDT) Message-ID: Date: Thu, 15 Jun 2023 13:17:17 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] drm/msm/dp: Free resources after unregistering them Content-Language: en-GB To: Bjorn Andersson , Rob Clark , Abhinav Kumar , Marijn Suijten , Kuogee Hsieh Cc: Sean Paul , David Airlie , Daniel Vetter , Johan Hovold , Vinod Polimera , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20230612220259.1884381-1-quic_bjorande@quicinc.com> From: Dmitry Baryshkov In-Reply-To: <20230612220259.1884381-1-quic_bjorande@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/06/2023 01:02, Bjorn Andersson wrote: > The DP component's unbind operation walks through the submodules to > unregister and clean things up. But if the unbind happens because the DP > controller itself is being removed, all the memory for those submodules > has just been freed. > > Change the order of these operations to avoid the many use-after-free > that otherwise happens in this code path. > > Fixes: c943b4948b58 ("drm/msm/dp: add displayPort driver support") > Signed-off-by: Bjorn Andersson > --- > drivers/gpu/drm/msm/dp/dp_display.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c > index bbb0550a022b..ebc84b8fddf8 100644 > --- a/drivers/gpu/drm/msm/dp/dp_display.c > +++ b/drivers/gpu/drm/msm/dp/dp_display.c > @@ -1337,9 +1337,9 @@ static int dp_display_remove(struct platform_device *pdev) > { > struct dp_display_private *dp = dev_get_dp_display_private(&pdev->dev); > > + component_del(&pdev->dev, &dp_display_comp_ops); > dp_display_deinit_sub_modules(dp); > > - component_del(&pdev->dev, &dp_display_comp_ops); > platform_set_drvdata(pdev, NULL); This matches more or less the order in dp_display_probe(). Reviewed-by: Dmitry Baryshkov A note for the possible followup: the driver initializes DP debugfs from dpu_kms (ugh) by calling msm_dp_debugfs_init() -> dp_debug_get(). I think that dp_debug_put() in dp_display_deinit_sub_modules() does not look correct. > > return 0; -- With best wishes Dmitry