Skip to content

Commit 0a96fa6

Browse files
HBh25Ygregkh
authored andcommitted
usb: misc: fix improper handling of refcount in uss720_probe()
usb_put_dev shouldn't be called when uss720_probe succeeds because of priv->usbdev. At the same time, priv->usbdev shouldn't be set to NULL before destroy_priv in uss720_disconnect because usb_put_dev is in destroy_priv. Fix this by moving priv->usbdev = NULL after usb_put_dev. Fixes: dcb4b8a ("misc/uss720: fix memory leak in uss720_probe") Cc: stable <[email protected]> Reviewed-by: Dongliang Mu <[email protected]> Signed-off-by: Hangyu Hua <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f085bd4 commit 0a96fa6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/usb/misc/uss720.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static void destroy_priv(struct kref *kref)
7171

7272
dev_dbg(&priv->usbdev->dev, "destroying priv datastructure\n");
7373
usb_put_dev(priv->usbdev);
74+
priv->usbdev = NULL;
7475
kfree(priv);
7576
}
7677

@@ -736,7 +737,6 @@ static int uss720_probe(struct usb_interface *intf,
736737
parport_announce_port(pp);
737738

738739
usb_set_intfdata(intf, pp);
739-
usb_put_dev(usbdev);
740740
return 0;
741741

742742
probe_abort:
@@ -754,7 +754,6 @@ static void uss720_disconnect(struct usb_interface *intf)
754754
usb_set_intfdata(intf, NULL);
755755
if (pp) {
756756
priv = pp->private_data;
757-
priv->usbdev = NULL;
758757
priv->pp = NULL;
759758
dev_dbg(&intf->dev, "parport_remove_port\n");
760759
parport_remove_port(pp);

0 commit comments

Comments
 (0)