USB: misc: uss720: unregister parport on probe failure
Subsystems (2)
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.
--- drivers/usb/misc/uss720.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/misc/uss720.c +4 -0
@@ -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
Quoted 7 lines · Myeonghun Pak
uss720_probe()registers a parport before reading the 1284 register used to detect unsupported Belkin F5U002 adapters. Ifget_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