Message ID | 20240217150228.5788-2-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp364303dyc; Sat, 17 Feb 2024 07:04:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLBbe6jn9af9PzDpPKco/QXMC8+b3ZsfkFeAocc9mYzivLOsER4QtICRFd6DI7cnzcUGeV4zGt//pCVt6HQHFVfAvsqA== X-Google-Smtp-Source: AGHT+IF6+wWt05JS6Y2erAfhOoC/OREYKPQe1K9mqZplPFkpIdpD88i/eb70voI0m3gguq64qR7N X-Received: by 2002:a17:906:a1cd:b0:a3d:6eb4:9768 with SMTP id bx13-20020a170906a1cd00b00a3d6eb49768mr4741637ejb.46.1708182287453; Sat, 17 Feb 2024 07:04:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182287; cv=pass; d=google.com; s=arc-20160816; b=YYP8L4nuXv0Kg2GzyQSCjLpXIUtXZ7BL+cSPE+oZMcvR7n3i26LwQJuc8KMPEqT144 I/PccfwEQgOj3Mh6VD9vRew0uyQpz3b3npUpOWExDFnZN6Puh+5fQZmvqa5hsi3L9Bbp Lbp6s0k+yMLK+6/dEsNscLBgM4YQV6AjCEh2SdVT2Ir89lS/IqXYrd9s7zbIjBWkT8kv vmvzqIJ4Uh24QHljiT8XdJeIMjH4G53qkU1vDG8PJ2HiwdhfTziokWvgUOKZFz5FOaER sydvhIaKjxaaWwww8LjcV7WoNLr7BhyijZ9NZr9DqxDzUob1VcWK4eVflxYWuDy2RgEl Ts2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X1yTF30tRRYkuEKzOUdIvpUcu3gPCLdfG/TO6+W1ENc=; fh=pcX3nLBLzYPdmuawBHbOhWNtQQD3frRXqpw6hcDvZ+Y=; b=O6t5E6Hb0RbiTiSZyb5FABaHwapI1OgkSLE//rKFhzVu49oUfpwPZ/8CBR/mck58oV iyNGC1gNif4vi1RxVLsO90/rTfMrtn4XgLyUm0zxxlaqZn8nA/jDfiiFWTfpzDrrMuvw SH76VXEZLNh1uw+WBBxR/g895FbJcTzh6dmOiiXRkJLWHWfzsXlUH8OR5OMKiRGKVZ9N BbPtirOXMoLl0XcO2aiZT0ODqN5GCQyKVkehG7NOP8yApcpehXhGupFDRKhBg3BHi4iv 8KNryiL957UA9Bbi7QUWSyB49V4DooGRdVf79oLro5wfyt3dZ0BDB3unFfCSaulVdGMg wdOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eEqGR0C+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l24-20020a1709065a9800b00a3da11e91d4si947565ejq.319.2024.02.17.07.04.47 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:04:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eEqGR0C+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EF09C1F219F6 for <ouuuleilei@gmail.com>; Sat, 17 Feb 2024 15:04:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 639FA7E567; Sat, 17 Feb 2024 15:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eEqGR0C+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96DF37C0B2; Sat, 17 Feb 2024 15:03:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; cv=none; b=CCoKO7Hg7fdIT2keUiUAWP01m1eXRKD8AKYcnEj0U6+FlihDjxcAh8Q+T2dnJypmoeIE9+irhjIxXl2Nendw+dUWsDyrSWp2VbXDptZeH6mG3Q2SoYSNzfpg4r1KkiDmkWexegV62kCSRwGBcPIegFIW3I2oE8k1M0oEqxJxoCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=POmhG3XikVsaXc0RusI64Jf3HUeMzGtS54gIumrv1I0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gy0UdPF/6SgLV2fqa2DD/a/eOGnC2H273mobdv9NNxfkgg9hs+wui+w78Tq3wRQSKx/X45K2+vLJLWxhDPXbEsfHOvMMrBgG6z6V5vhWDT45eYGUrDpbotiMQNTzsnNJIRvxX23zP6lrVC/RPfc+qr0i72CB4rHWjoP3EQTZScM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eEqGR0C+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17518C433B1; Sat, 17 Feb 2024 15:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=POmhG3XikVsaXc0RusI64Jf3HUeMzGtS54gIumrv1I0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eEqGR0C+9C6T6cV2g4R/ygaPvBNcGscgTTbDfWpt6RqNCVCSNemlDmMiBjLINFF9K vNOWBEXAul5FUj2axKYGDdckCtDO4TfXoy/tk+8sx+M+Nax3pT9M4+S/bHKHCxiynt JVidLDi1X3iyquM1kp0a0kub0LV/yLpN3RHEru2kNVYZ1+NxnuinFZsD6q3h74J/bF QqKCFNwEidPJOkwPHGJM73U2yVQ+4BuksOAvfFpAIVLuaZV050HXeu1xqCZl2QDBHY upv4mvxbKoOiSRj0B/wbcx4RIR8QiHUJlV8SjhAA3Z57ya1yYljjfWRvPgLGCifDKc 1sh5+H+c0Jn0g== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from <johan+linaro@kernel.org>) id 1rbMDW-000000001Vo-2L8p; Sat, 17 Feb 2024 16:03:02 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Bjorn Andersson <andersson@kernel.org>, Andrzej Hajda <andrzej.hajda@intel.com>, Neil Armstrong <neil.armstrong@linaro.org>, Robert Foss <rfoss@kernel.org>, Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Vinod Koul <vkoul@kernel.org> Cc: Jonas Karlman <jonas@kwiboo.se>, Laurent Pinchart <Laurent.pinchart@ideasonboard.com>, Jernej Skrabec <jernej.skrabec@gmail.com>, Konrad Dybcio <konrad.dybcio@linaro.org>, Kishon Vijay Abraham I <kishon@kernel.org>, Dmitry Baryshkov <dmitry.baryshkov@linaro.org>, Rob Clark <robdclark@gmail.com>, Abhinav Kumar <quic_abhinavk@quicinc.com>, Kuogee Hsieh <quic_khsieh@quicinc.com>, freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Johan Hovold <johan+linaro@kernel.org> Subject: [PATCH 1/6] drm/bridge: aux-hpd: fix OF node leaks Date: Sat, 17 Feb 2024 16:02:23 +0100 Message-ID: <20240217150228.5788-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791158950250252667 X-GMAIL-MSGID: 1791158950250252667 |
Series |
soc: qcom: pmic_glink_altmode: fix drm bridge use-after-free
|
|
Commit Message
Johan Hovold
Feb. 17, 2024, 3:02 p.m. UTC
The two device node references taken during allocation need to be
dropped when the auxiliary device is freed.
Fixes: 6914968a0b52 ("drm/bridge: properly refcount DT nodes in aux bridge drivers")
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/gpu/drm/bridge/aux-hpd-bridge.c | 3 +++
1 file changed, 3 insertions(+)
Comments
> The two device node references taken during allocation need to be > dropped when the auxiliary device is freed. … > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c … > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > ret = auxiliary_device_init(adev); > if (ret) { > + of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > kfree(adev); > return ERR_PTR(ret); The last two statements are also used in a previous if branch. https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/bridge/aux-hpd-bridge.c#L63 How do you think about to avoid such a bit of duplicate source code by adding a label here? Regards, Markus
On Mon, Feb 19, 2024 at 06:48:30PM +0100, Markus Elfring wrote: > > The two device node references taken during allocation need to be > > dropped when the auxiliary device is freed. > … > > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > … > > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > > > ret = auxiliary_device_init(adev); > > if (ret) { > > + of_node_put(adev->dev.platform_data); > > + of_node_put(adev->dev.of_node); > > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > kfree(adev); > > return ERR_PTR(ret); > > The last two statements are also used in a previous if branch. > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/bridge/aux-hpd-bridge.c#L63 > > How do you think about to avoid such a bit of duplicate source code > by adding a label here? No, the current code is fine and what you are suggesting is in any case unrelated to this fix. If this function ever grows a third error path like that, I too would consider it however. Johan
On Tue, 20 Feb 2024, Johan Hovold wrote: > On Mon, Feb 19, 2024 at 06:48:30PM +0100, Markus Elfring wrote: > > > The two device node references taken during allocation need to be > > > dropped when the auxiliary device is freed. > > … > > > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > > … > > > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > > > > > ret = auxiliary_device_init(adev); > > > if (ret) { > > > + of_node_put(adev->dev.platform_data); > > > + of_node_put(adev->dev.of_node); > > > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > > kfree(adev); > > > return ERR_PTR(ret); > > > > The last two statements are also used in a previous if branch. > > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/bridge/aux-hpd-bridge.c#L63 > > > > How do you think about to avoid such a bit of duplicate source code > > by adding a label here? > > No, the current code is fine and what you are suggesting is in any case > unrelated to this fix. > > If this function ever grows a third error path like that, I too would > consider it however. I guess these of_node_puts can all go away shortly with cleanup anyway? julia
On Tue, 20 Feb 2024 at 13:52, Julia Lawall <julia.lawall@inria.fr> wrote: > > > > On Tue, 20 Feb 2024, Johan Hovold wrote: > > > On Mon, Feb 19, 2024 at 06:48:30PM +0100, Markus Elfring wrote: > > > > The two device node references taken during allocation need to be > > > > dropped when the auxiliary device is freed. > > > … > > > > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > > > … > > > > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > > > > > > > ret = auxiliary_device_init(adev); > > > > if (ret) { > > > > + of_node_put(adev->dev.platform_data); > > > > + of_node_put(adev->dev.of_node); > > > > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > > > kfree(adev); > > > > return ERR_PTR(ret); > > > > > > The last two statements are also used in a previous if branch. > > > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/bridge/aux-hpd-bridge.c#L63 > > > > > > How do you think about to avoid such a bit of duplicate source code > > > by adding a label here? > > > > No, the current code is fine and what you are suggesting is in any case > > unrelated to this fix. > > > > If this function ever grows a third error path like that, I too would > > consider it however. > > I guess these of_node_puts can all go away shortly with cleanup anyway? I'm not sure about it. Those are long-living variables, so they are not a subject of cleanup.h, are they?
On Tue, 20 Feb 2024, Dmitry Baryshkov wrote: > On Tue, 20 Feb 2024 at 13:52, Julia Lawall <julia.lawall@inria.fr> wrote: > > > > > > > > On Tue, 20 Feb 2024, Johan Hovold wrote: > > > > > On Mon, Feb 19, 2024 at 06:48:30PM +0100, Markus Elfring wrote: > > > > > The two device node references taken during allocation need to be > > > > > dropped when the auxiliary device is freed. > > > > … > > > > > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > > > > … > > > > > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > > > > > > > > > ret = auxiliary_device_init(adev); > > > > > if (ret) { > > > > > + of_node_put(adev->dev.platform_data); > > > > > + of_node_put(adev->dev.of_node); > > > > > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > > > > kfree(adev); > > > > > return ERR_PTR(ret); > > > > > > > > The last two statements are also used in a previous if branch. > > > > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/bridge/aux-hpd-bridge.c#L63 > > > > > > > > How do you think about to avoid such a bit of duplicate source code > > > > by adding a label here? > > > > > > No, the current code is fine and what you are suggesting is in any case > > > unrelated to this fix. > > > > > > If this function ever grows a third error path like that, I too would > > > consider it however. > > > > I guess these of_node_puts can all go away shortly with cleanup anyway? > > I'm not sure about it. Those are long-living variables, so they are > not a subject of cleanup.h, are they? OK, I didn't look at this code in detail, but cleanup would just call of_node_put, not actually free the data. julia
On Tue, 20 Feb 2024 at 14:56, Julia Lawall <julia.lawall@inria.fr> wrote: > > > > On Tue, 20 Feb 2024, Dmitry Baryshkov wrote: > > > On Tue, 20 Feb 2024 at 13:52, Julia Lawall <julia.lawall@inria.fr> wrote: > > > > > > > > > > > > On Tue, 20 Feb 2024, Johan Hovold wrote: > > > > > > > On Mon, Feb 19, 2024 at 06:48:30PM +0100, Markus Elfring wrote: > > > > > > The two device node references taken during allocation need to be > > > > > > dropped when the auxiliary device is freed. > > > > > … > > > > > > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > > > > > … > > > > > > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > > > > > > > > > > > ret = auxiliary_device_init(adev); > > > > > > if (ret) { > > > > > > + of_node_put(adev->dev.platform_data); > > > > > > + of_node_put(adev->dev.of_node); > > > > > > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > > > > > kfree(adev); > > > > > > return ERR_PTR(ret); > > > > > > > > > > The last two statements are also used in a previous if branch. > > > > > https://elixir.bootlin.com/linux/v6.8-rc5/source/drivers/gpu/drm/bridge/aux-hpd-bridge.c#L63 > > > > > > > > > > How do you think about to avoid such a bit of duplicate source code > > > > > by adding a label here? > > > > > > > > No, the current code is fine and what you are suggesting is in any case > > > > unrelated to this fix. > > > > > > > > If this function ever grows a third error path like that, I too would > > > > consider it however. > > > > > > I guess these of_node_puts can all go away shortly with cleanup anyway? > > > > I'm not sure about it. Those are long-living variables, so they are > > not a subject of cleanup.h, are they? > > OK, I didn't look at this code in detail, but cleanup would just call > of_node_put, not actually free the data. Yes. The nodes should be put either in case of the failure or (if everything goes fine) at the device unregistration.
On Sat, Feb 17, 2024 at 04:02:23PM +0100, Johan Hovold wrote: > The two device node references taken during allocation need to be > dropped when the auxiliary device is freed. > > Fixes: 6914968a0b52 ("drm/bridge: properly refcount DT nodes in aux bridge drivers") > Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Cc: Neil Armstrong <neil.armstrong@linaro.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Reviewed-by: Bjorn Andersson <andersson@kernel.org> Regards, Bjorn > --- > drivers/gpu/drm/bridge/aux-hpd-bridge.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > index bb55f697a181..9e71daf95bde 100644 > --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > @@ -25,6 +25,7 @@ static void drm_aux_hpd_bridge_release(struct device *dev) > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > > kfree(adev); > } > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > ret = auxiliary_device_init(adev); > if (ret) { > + of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > kfree(adev); > return ERR_PTR(ret); > -- > 2.43.0 >
On Sat, 17 Feb 2024 at 17:03, Johan Hovold <johan+linaro@kernel.org> wrote: > > The two device node references taken during allocation need to be > dropped when the auxiliary device is freed. > > Fixes: 6914968a0b52 ("drm/bridge: properly refcount DT nodes in aux bridge drivers") > Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Cc: Neil Armstrong <neil.armstrong@linaro.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > --- > drivers/gpu/drm/bridge/aux-hpd-bridge.c | 3 +++ > 1 file changed, 3 insertions(+)
On 17/02/2024 16:02, Johan Hovold wrote: > The two device node references taken during allocation need to be > dropped when the auxiliary device is freed. > > Fixes: 6914968a0b52 ("drm/bridge: properly refcount DT nodes in aux bridge drivers") > Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Cc: Neil Armstrong <neil.armstrong@linaro.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > --- > drivers/gpu/drm/bridge/aux-hpd-bridge.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > index bb55f697a181..9e71daf95bde 100644 > --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > @@ -25,6 +25,7 @@ static void drm_aux_hpd_bridge_release(struct device *dev) > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > > kfree(adev); > } > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > ret = auxiliary_device_init(adev); > if (ret) { > + of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > kfree(adev); > return ERR_PTR(ret); Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
On 17/02/2024 16:02, Johan Hovold wrote: > The two device node references taken during allocation need to be > dropped when the auxiliary device is freed. > > Fixes: 6914968a0b52 ("drm/bridge: properly refcount DT nodes in aux bridge drivers") > Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> > Cc: Neil Armstrong <neil.armstrong@linaro.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > --- > drivers/gpu/drm/bridge/aux-hpd-bridge.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > index bb55f697a181..9e71daf95bde 100644 > --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c > +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c > @@ -25,6 +25,7 @@ static void drm_aux_hpd_bridge_release(struct device *dev) > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > > of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > > kfree(adev); > } > @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, > > ret = auxiliary_device_init(adev); > if (ret) { > + of_node_put(adev->dev.platform_data); > + of_node_put(adev->dev.of_node); > ida_free(&drm_aux_hpd_bridge_ida, adev->id); > kfree(adev); > return ERR_PTR(ret); Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c index bb55f697a181..9e71daf95bde 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -25,6 +25,7 @@ static void drm_aux_hpd_bridge_release(struct device *dev) ida_free(&drm_aux_hpd_bridge_ida, adev->id); of_node_put(adev->dev.platform_data); + of_node_put(adev->dev.of_node); kfree(adev); } @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, ret = auxiliary_device_init(adev); if (ret) { + of_node_put(adev->dev.platform_data); + of_node_put(adev->dev.of_node); ida_free(&drm_aux_hpd_bridge_ida, adev->id); kfree(adev); return ERR_PTR(ret);