mirror of
https://github.com/torvalds/linux.git
synced 2026-01-12 00:42:35 +08:00
gpio: mpsse: fix reference leak in gpio_mpsse_probe() error paths
The reference obtained by calling usb_get_dev() is not released in the
gpio_mpsse_probe() error paths. Fix that by using device managed helper
functions. Also remove the usb_put_dev() call in the disconnect function
since now it will be released automatically.
Cc: stable@vger.kernel.org
Fixes: c46a74ff05 ("gpio: add support for FTDI's MPSSE as GPIO")
Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Link: https://lore.kernel.org/r/20251226060414.20785-1-nihaal@cse.iitm.ac.in
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
014a17deb4
commit
1e876e5a08
@@ -548,6 +548,13 @@ static void gpio_mpsse_ida_remove(void *data)
|
||||
ida_free(&gpio_mpsse_ida, priv->id);
|
||||
}
|
||||
|
||||
static void gpio_mpsse_usb_put_dev(void *data)
|
||||
{
|
||||
struct mpsse_priv *priv = data;
|
||||
|
||||
usb_put_dev(priv->udev);
|
||||
}
|
||||
|
||||
static int mpsse_init_valid_mask(struct gpio_chip *chip,
|
||||
unsigned long *valid_mask,
|
||||
unsigned int ngpios)
|
||||
@@ -592,6 +599,10 @@ static int gpio_mpsse_probe(struct usb_interface *interface,
|
||||
INIT_LIST_HEAD(&priv->workers);
|
||||
|
||||
priv->udev = usb_get_dev(interface_to_usbdev(interface));
|
||||
err = devm_add_action_or_reset(dev, gpio_mpsse_usb_put_dev, priv);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
priv->intf = interface;
|
||||
priv->intf_id = interface->cur_altsetting->desc.bInterfaceNumber;
|
||||
|
||||
@@ -713,7 +724,6 @@ static void gpio_mpsse_disconnect(struct usb_interface *intf)
|
||||
|
||||
priv->intf = NULL;
|
||||
usb_set_intfdata(intf, NULL);
|
||||
usb_put_dev(priv->udev);
|
||||
}
|
||||
|
||||
static struct usb_driver gpio_mpsse_driver = {
|
||||
|
||||
Reference in New Issue
Block a user