From: Vladimir Zapolskiy <vz@mleia.com>
To: Johan Hovold <johan@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Piotr Wojtaszczyk <piotr.wojtaszczyk@timesys.com>,
Alan Stern <stern@rowland.harvard.edu>,
Ma Ke <make24@iscas.ac.cn>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2 2/5] usb: phy: isp1301: fix non-OF device reference imbalance
Date: Fri, 19 Dec 2025 02:15:12 +0200 [thread overview]
Message-ID: <71adaa7f-808a-47df-85ed-55ec12da4561@mleia.com> (raw)
In-Reply-To: <20251218153519.19453-3-johan@kernel.org>
On 12/18/25 17:35, Johan Hovold wrote:
> A recent change fixing a device reference leak in a UDC driver
> introduced a potential use-after-free in the non-OF case as the
> isp1301_get_client() helper only increases the reference count for the
> returned I2C device in the OF case.
Fortunatly there is no non-OF users of this driver, it's been discussed
recently.
>
> Increment the reference count also for non-OF so that the caller can
> decrement it unconditionally.
>
> Note that this is inherently racy just as using the returned I2C device
> is since nothing is preventing the PHY driver from being unbound while
> in use.
>
> Fixes: c84117912bdd ("USB: lpc32xx_udc: Fix error handling in probe")
> Cc: stable@vger.kernel.org
> Cc: Ma Ke <make24@iscas.ac.cn>
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/usb/phy/phy-isp1301.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
> index f9b5c411aee4..2940f0c84e1b 100644
> --- a/drivers/usb/phy/phy-isp1301.c
> +++ b/drivers/usb/phy/phy-isp1301.c
> @@ -149,7 +149,12 @@ struct i2c_client *isp1301_get_client(struct device_node *node)
> return client;
>
> /* non-DT: only one ISP1301 chip supported */
> - return isp1301_i2c_client;
> + if (isp1301_i2c_client) {
> + get_device(&isp1301_i2c_client->dev);
> + return isp1301_i2c_client;
> + }
> +
> + return NULL;
> }
> EXPORT_SYMBOL_GPL(isp1301_get_client);
>
Okay, let's go the way of fixing the broken commit instead of its reversal.
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
--
Best wishes,
Vladimir
next prev parent reply other threads:[~2025-12-19 0:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 15:35 [PATCH v2 0/5] USB: lpc32xx: fix error handling Johan Hovold
2025-12-18 15:35 ` [PATCH v2 1/5] usb: gadget: lpc32xx_udc: fix clock imbalance in error path Johan Hovold
2025-12-19 0:11 ` Vladimir Zapolskiy
2025-12-18 15:35 ` [PATCH v2 2/5] usb: phy: isp1301: fix non-OF device reference imbalance Johan Hovold
2025-12-19 0:15 ` Vladimir Zapolskiy [this message]
2025-12-19 6:20 ` Johan Hovold
2025-12-18 15:35 ` [PATCH v2 3/5] usb: ohci-nxp: fix device leak on probe failure Johan Hovold
2025-12-18 15:52 ` Alan Stern
2025-12-19 0:19 ` Vladimir Zapolskiy
2025-12-18 15:35 ` [PATCH v2 4/5] usb: gadget: lpc32xx_udc: clean up probe error labels Johan Hovold
2025-12-19 0:22 ` Vladimir Zapolskiy
2025-12-18 15:35 ` [PATCH v2 5/5] usb: ohci-nxp: " Johan Hovold
2025-12-19 0:22 ` Vladimir Zapolskiy
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=71adaa7f-808a-47df-85ed-55ec12da4561@mleia.com \
--to=vz@mleia.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=piotr.wojtaszczyk@timesys.com \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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