Commit e34139c
usb: fix reference leak in usb_new_device()
BugLink: https://bugs.launchpad.net/bugs/2097298
commit 0df11fa upstream.
When device_add(&udev->dev) succeeds and a later call fails,
usb_new_device() does not properly call device_del(). As comment of
device_add() says, 'if device_add() succeeds, you should call
device_del() when you want to get rid of it. If device_add() has not
succeeded, use only put_device() to drop the reference count'.
Found by code review.
Cc: stable <stable@kernel.org>
Fixes: 9f8b17e ("USB: make usbdevices export their device nodes instead of using a separate class")
Signed-off-by: Ma Ke <make_ruc2021@163.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20241218071346.2973980-1-make_ruc2021@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Noah Wager <noah.wager@canonical.com>
Signed-off-by: Koichiro Den <koichiro.den@canonical.com>1 parent 1da8373 commit e34139c
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2605 | 2605 | | |
2606 | 2606 | | |
2607 | 2607 | | |
2608 | | - | |
| 2608 | + | |
2609 | 2609 | | |
2610 | 2610 | | |
2611 | 2611 | | |
2612 | 2612 | | |
2613 | 2613 | | |
2614 | | - | |
| 2614 | + | |
2615 | 2615 | | |
2616 | 2616 | | |
2617 | 2617 | | |
| |||
2623 | 2623 | | |
2624 | 2624 | | |
2625 | 2625 | | |
| 2626 | + | |
| 2627 | + | |
2626 | 2628 | | |
2627 | 2629 | | |
2628 | 2630 | | |
| |||
0 commit comments