All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/bridge: display-connector: Fix DDC adapter leak in display_connector_probe()
Date: Wed, 16 Sep 2026 10:15:30 +0000	[thread overview]
Message-ID: <20260916101531.5CEE61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916100547.2012828-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/bridge: display-connector: double-put of I2C adapter on probe failure
--

commit 6664228340b6b3ba7c429f5b94a033d13e1f4e21
Author: Wentao Liang <vulab@iscas.ac.cn>

drm/bridge: display-connector: Fix DDC adapter leak in display_connector_probe()

This commit explicitly drops the DDC adapter reference on error paths in
display_connector_probe() to prevent a resource leak when probe fails after
obtaining the adapter.

> diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
> index eb3412ec30a07..e7e9c40dbdd97 100644
> --- a/drivers/gpu/drm/bridge/display-connector.c
> +++ b/drivers/gpu/drm/bridge/display-connector.c
> @@ -394,18 +394,22 @@ static int display_connector_probe(struct platform_device *pdev)
>  
>  		if (IS_ERR(conn->ddc_en)) {
>  			dev_err(&pdev->dev, "Couldn't get ddc-en gpio\n");
> +			i2c_put_adapter(conn->bridge.ddc);

[Severity: High]
Could this result in a double-put of the I2C adapter when returning an error?

Since the display_connector structure is allocated earlier using
devm_drm_bridge_alloc(), returning an error will trigger the devres cleanup
action. This cleanup calls drm_bridge_put(), which invokes the bridge's
destroy callback, display_connector_destroy().

Looking at display_connector_destroy(), it already releases the adapter:

static void display_connector_destroy(struct drm_bridge *bridge)
{
        struct display_connector *conn = bridge_to_display_connector(bridge);
        ...
        i2c_put_adapter(conn->bridge.ddc);
        ...
}

If we explicitly call i2c_put_adapter() here without also setting
conn->bridge.ddc to NULL, will the devres cleanup path put the adapter a
second time and cause a refcount underflow?

>  			return PTR_ERR(conn->ddc_en);
>  		}
>  
>  		ret = display_connector_get_supply(pdev, conn, "hdmi-pwr");
> -		if (ret < 0)
> +		if (ret < 0) {
> +			i2c_put_adapter(conn->bridge.ddc);

[Severity: High]
Does this also suffer from the same devres double-put regression during
cleanup?

>  			return dev_err_probe(&pdev->dev, ret, "failed to get HDMI +5V Power regulator\n");
> +		}
>  	}
>  
>  	if (conn->supply) {
>  		ret = regulator_enable(conn->supply);
>  		if (ret) {
>  			dev_err(&pdev->dev, "failed to enable PWR regulator: %d\n", ret);
> +			i2c_put_adapter(conn->bridge.ddc);

[Severity: High]
Does this path similarly trigger a double-put via
display_connector_destroy() when returning the error?

>  			return ret;
>  		}
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260916100547.2012828-1-vulab@iscas.ac.cn?part=1

      reply	other threads:[~2026-09-16 10:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-16 10:05 [PATCH] drm/bridge: display-connector: Fix DDC adapter leak in display_connector_probe() Wentao Liang
2026-09-16 10:15 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260916101531.5CEE61F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vulab@iscas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.