Skip to contentSkip to conversation

USB: misc: uss720: unregister parport on probe failure

PATCH Superseded Myeonghun Pak 2 participants 2 messages Jul 1 – Jul 2

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: misc: uss720: unregister parport on probe failure

uss720_probe() registers a parport before reading the 1284 register used to detect unsupported Belkin F5U002 adapters. If get_1284_register() fails, the error path drops the driver private data and the USB device reference, but leaves the parport device registered.

Undo the pre-announce registration with parport_del_port(). Clear priv->pp before unregistering the port, matching the disconnect path and avoiding leaving a stale pointer in the private data.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 3295f1b866bf ("usb: misc: uss720: check for incompatible versions of the Belkin F5U002")
---
 drivers/usb/misc/uss720.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/usb/misc/uss720.c +4 -0
index a8af7615b1..8a5ffb19a5 100644
@@ -749,6 +749,10 @@ static int uss720_probe(struct usb_interface *intf,
 	return 0;
 
 probe_abort:
+	if (pp) {
+		priv->pp = NULL;
+		parport_del_port(pp);
+	}
 	kill_all_async_requests_priv(priv);
 	kref_put(&priv->ref_count, destroy_priv);
 	return -ENODEV;
Signature · 1 line
2.47.1
#1 lore raw
Quoted 7 lines · Myeonghun Pak

uss720_probe() registers a parport before reading the 1284 register used to detect unsupported Belkin F5U002 adapters. If get_1284_register() fails, the error path drops the driver private data and the USB device reference, but leaves the parport device registered.

probe_abort:

drivers/usb/misc/uss720.c static int uss720_probe(struct usb_interface *intf, · line 758

Quoted 7 lines
drivers/usb/misc/uss720.c +4 -0
+       if (pp) {
+               priv->pp = NULL;
+               parport_del_port(pp);
+       }
        kill_all_async_requests_priv(priv);
        kref_put(&priv->ref_count, destroy_priv);
        return -ENODEV;

I think it would make more sense to set priv->pp to NULL and call parport_del_port(pp) right before the second goto probe_abort instead of calling parport_del_port in probe_abort. That would avoid the need for checking whether pp is null before cleaning it up.

Is this just a memory leak, or is there some visible negative consequence to not cleaning up the struct parport on failure?

-Alex