Skip to contentSkip to conversation

usb: misc: fix refcount leak in get_1284_register()

PATCH New WenTao Liang 1 participant 1 message Jun 11

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

PATCH 1/1 usb: misc: fix refcount leak in get_1284_register()

In get_1284_register(), submit_async_request() returns an "rq" object with a caller's reference. If the subsequent wait_for_completion_timeout() times out, the error path calls kill_all_async_requests_priv() to cancel pending URBs, but it fails to drop that caller's reference. All other paths (early exit on !val and the successful completion path) correctly call kref_put() to release the reference. This leak results in the memory allocated for the request never being freed.

Fix the timeout path by adding the missing kref_put() call before returning -EIO.

Fixes 0f36163d3abe ("[PATCH] usb: fix uss720 schedule with interrupts off")
---
 drivers/usb/misc/uss720.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/misc/uss720.c +1 -0
index e1eba3cbef0a..ca97d77cfe2e 100644
@@ -223,6 +223,7 @@ static int get_1284_register(struct parport *pp, unsigned char reg, unsigned cha
 	}
 	printk(KERN_WARNING "get_1284_register timeout\n");
 	kill_all_async_requests_priv(priv);
+	kref_put(&rq->ref_count, destroy_async);
 	return -EIO;
 }
 
Signature · 1 line
2.50.1 (Apple Git-155)