From: Patrice CHOTARD <patrice.chotard@foss.st.com>
To: Wentao Liang <vulab@iscas.ac.cn>, <andi.shyti@kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<maxime.coquelin@st.com>, <wsa@kernel.org>,
<stable@vger.kernel.org>
Subject: Re: [PATCH] i2c: st: Fix clock reference leak in st_i2c_probe()
Date: Thu, 17 Sep 2026 11:13:14 +0200 [thread overview]
Message-ID: <c5cf542c-46eb-47c5-9424-a7bc3ce630ab@foss.st.com> (raw)
In-Reply-To: <20260916160235.2080462-1-vulab@iscas.ac.cn>
On 9/16/26 18:02, Wentao Liang wrote:
> The clock obtained with of_clk_get_by_name() is never released: the
> probe error paths after it, irq request failure, deglitch setup
> failure and adapter registration failure, return without clk_put(),
> and st_i2c_remove() does not drop the reference either.
>
> Add a cleanup label that drops the clock reference on the probe error
> paths and release the reference in the remove path.
>
> Fixes: 85b4fab26960 ("i2c: i2c-st: Add ST I2C controller")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/i2c/busses/i2c-st.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-st.c b/drivers/i2c/busses/i2c-st.c
> index 751ea421caaf..2049bbce3656 100644
> --- a/drivers/i2c/busses/i2c-st.c
> +++ b/drivers/i2c/busses/i2c-st.c
> @@ -831,7 +831,7 @@ static int st_i2c_probe(struct platform_device *pdev)
> IRQF_ONESHOT, pdev->name, i2c_dev);
> if (ret) {
> dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq);
> - return ret;
> + goto err_clk;
> }
>
> pinctrl_pm_select_default_state(i2c_dev->dev);
> @@ -840,7 +840,7 @@ static int st_i2c_probe(struct platform_device *pdev)
>
> ret = st_i2c_of_get_deglitch(np, i2c_dev);
> if (ret)
> - return ret;
> + goto err_clk;
>
> adap = &i2c_dev->adap;
> i2c_set_adapdata(adap, i2c_dev);
> @@ -857,13 +857,17 @@ static int st_i2c_probe(struct platform_device *pdev)
>
> ret = i2c_add_adapter(adap);
> if (ret)
> - return ret;
> + goto err_clk;
>
> platform_set_drvdata(pdev, i2c_dev);
>
> dev_info(i2c_dev->dev, "%s initialized\n", adap->name);
>
> return 0;
> +
> +err_clk:
> + clk_put(i2c_dev->clk);
> + return ret;
> }
>
> static void st_i2c_remove(struct platform_device *pdev)
> @@ -871,6 +875,7 @@ static void st_i2c_remove(struct platform_device *pdev)
> struct st_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
>
> i2c_del_adapter(&i2c_dev->adap);
> + clk_put(i2c_dev->clk);
> }
>
> static const struct of_device_id st_i2c_match[] = {
Hi Wentao
This patch need to be rebased on last kernel.
Thanks
Patrice
prev parent reply other threads:[~2026-09-17 9:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:02 [PATCH] i2c: st: Fix clock reference leak in st_i2c_probe() Wentao Liang
2026-09-17 9:13 ` Patrice CHOTARD [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=c5cf542c-46eb-47c5-9424-a7bc3ce630ab@foss.st.com \
--to=patrice.chotard@foss.st.com \
--cc=andi.shyti@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.coquelin@st.com \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
--cc=wsa@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox