Skip to contentSkip to conversation

tablet: acecad: update the reference count of the usb interface structure

PATCH In review Salah Triki 2 participants 4 messages Jul 24, 2021 – Jul 29, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tablet: acecad: update the reference count of the usb interface structure

Use usb_get_intf() and usb_put_intf() in order to update the reference count of the usb interface structure.

---
 drivers/input/tablet/acecad.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/input/tablet/acecad.c +4 -1
index a38d1fe97334..85fe134a30ee 100644
@@ -151,7 +151,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
 		goto fail2;
 	}
 
-	acecad->intf = intf;
+	acecad->intf = usb_get_intf(intf);
 	acecad->input = input_dev;
 
 	if (dev->manufacturer)
@@ -236,6 +236,9 @@ static void usb_acecad_disconnect(struct usb_interface *intf)
 	input_unregister_device(acecad->input);
 	usb_free_urb(acecad->irq);
 	usb_free_coherent(udev, 8, acecad->data, acecad->data_dma);
+
+	usb_put_intf(acecad->intf);
+
 	kfree(acecad);
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Salah Triki

Use usb_get_intf() and usb_put_intf() in order to update the reference count of the usb interface structure.

This commit message doesn't say what the user visible effects are. If you encountered this bug at runtime then please put the stack trace in the commit mesage.

Add a Fixes tag.

Quoted 10 lines
---
 drivers/input/tablet/acecad.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/input/tablet/acecad.c +0 -0
index a38d1fe97334..85fe134a30ee 100644

drivers/input/tablet/acecad.c static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_ · line 157

Quoted 8 lines
drivers/input/tablet/acecad.c +1 -1
@@ -151,7 +151,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
 		goto fail2;
 	}
 
-	acecad->intf = intf;
+	acecad->intf = usb_get_intf(intf);
 	acecad->input = input_dev;
 
 	if (dev->manufacturer)

You need to call usb_put_intf() if input_register_device() fails.

regards,
dan carpenter

#2 lore raw
Quoted 4 lines · Dan Carpenter

This commit message doesn't say what the user visible effects are. If you encountered this bug at runtime then please put the stack trace in the commit mesage.

I made this patch based on the following documentation of usb_get_intf():

[quote]
Each live reference to a interface must be refcounted.

Drivers for USB interfaces should normally record such references in their probe methods, when they bind to an interface, and release them by calling usb_put_intf, in their disconnect methods.

[/quote]

Thanx

#3 lore raw
Quoted 9 lines · Salah Triki
Quoted 4 lines · Dan Carpenter

This commit message doesn't say what the user visible effects are. If you encountered this bug at runtime then please put the stack trace in the commit mesage.

I made this patch based on the following documentation of usb_get_intf():

Quoted 8 lines

[quote]
Each live reference to a interface must be refcounted.

Drivers for USB interfaces should normally record such references in their probe methods, when they bind to an interface, and release them by calling usb_put_intf, in their disconnect methods.

[/quote]

Put that information in the commit message. Otherwise to review this patch then I'm trying to look through the syzbot dashboard to find the stack trace.

regards,
dan carpenter