Skip to content

Commit b4b64fd

Browse files
jhovoldgregkh
authored andcommitted
usb: phy: isp1301: fix non-OF device reference imbalance
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. 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: c841179 ("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> Reviewed-by: Vladimir Zapolskiy <vz@mleia.com> Link: https://patch.msgid.link/20251218153519.19453-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 782be79 commit b4b64fd

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/usb/phy/phy-isp1301.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ struct i2c_client *isp1301_get_client(struct device_node *node)
149149
return client;
150150

151151
/* non-DT: only one ISP1301 chip supported */
152-
return isp1301_i2c_client;
152+
if (isp1301_i2c_client) {
153+
get_device(&isp1301_i2c_client->dev);
154+
return isp1301_i2c_client;
155+
}
156+
157+
return NULL;
153158
}
154159
EXPORT_SYMBOL_GPL(isp1301_get_client);
155160

0 commit comments

Comments
 (0)