From: sashiko-bot@kernel.org
To: "Johan Hovold" <johan@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/mediatek: mtk_hdmi_common: take i2c adapter module reference
Date: Thu, 16 Jul 2026 13:36:48 +0000 [thread overview]
Message-ID: <20260716133648.925D51F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260716132103.1564995-1-johan@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Double-free of I2C adapter device and module references during driver unbind due to conflicting manual and devm cleanups.
--
--- Patch [1]: [PATCH] drm/mediatek: mtk_hdmi_common: take i2c adapter module reference ---
commit cbad79e276722919c8f55731b14f0b51837c5548
Author: Johan Hovold <johan@kernel.org>
drm/mediatek: mtk_hdmi_common: take i2c adapter module reference
The patch switches to of_get_i2c_adapter_by_node() which grabs a
module reference, allowing graceful module unload failures instead
of uninterruptible blocking. It updates the devm action to call
mtk_hdmi_put_adapter which wraps i2c_put_adapter.
> diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi_common.c b/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
> index a049489daa2d7..042b98e5a5199 100644
> --- a/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
> +++ b/drivers/gpu/drm/mediatek/mtk_hdmi_common.c
[ ... ]
> @@ -328,12 +335,12 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, struct platform_device
> if (!i2c_np)
> return dev_err_probe(dev, -EINVAL, "No ddc-i2c-bus in connector\n");
>
> - hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
> + hdmi->ddc_adpt = of_get_i2c_adapter_by_node(i2c_np);
> of_node_put(i2c_np);
> if (!hdmi->ddc_adpt)
> return dev_err_probe(dev, -EPROBE_DEFER, "Failed to get ddc i2c adapter by node\n");
>
> - ret = devm_add_action_or_reset(dev, mtk_hdmi_put_device, &hdmi->ddc_adpt->dev);
> + ret = devm_add_action_or_reset(dev, mtk_hdmi_put_adapter, hdmi->ddc_adpt);
[Severity: High]
This is a pre-existing issue, but does this devm cleanup conflict with a
manual cleanup during driver unbind?
Looking at mtk_hdmi_v2_remove() in drivers/gpu/drm/mediatek/mtk_hdmi_v2.c,
there is a manual call to i2c_put_adapter(hdmi->ddc_adpt).
When the driver unbinds, mtk_hdmi_v2_remove() will run and release the
adapter. After the remove callback returns, the device core will execute
the devres action registered here. This will invoke mtk_hdmi_put_adapter()
and call i2c_put_adapter() a second time on the same pointer.
Will this result in a double-free of the I2C adapter device and a double
module_put()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260716132103.1564995-1-johan@kernel.org?part=1
prev parent reply other threads:[~2026-07-16 13:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 13:21 [PATCH] drm/mediatek: mtk_hdmi_common: take i2c adapter module reference Johan Hovold
2026-07-16 13:36 ` 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=20260716133648.925D51F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=johan@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.