Commit c6e7b38
usb: fix reference leak in usb_new_device()
BugLink: https://bugs.launchpad.net/bugs/2106770
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: Manuel Diewald <manuel.diewald@canonical.com>
Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>1 parent 98f5ecb commit c6e7b38
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2635 | 2635 | | |
2636 | 2636 | | |
2637 | 2637 | | |
2638 | | - | |
| 2638 | + | |
2639 | 2639 | | |
2640 | 2640 | | |
2641 | 2641 | | |
2642 | 2642 | | |
2643 | 2643 | | |
2644 | | - | |
| 2644 | + | |
2645 | 2645 | | |
2646 | 2646 | | |
2647 | 2647 | | |
| |||
2655 | 2655 | | |
2656 | 2656 | | |
2657 | 2657 | | |
| 2658 | + | |
| 2659 | + | |
2658 | 2660 | | |
2659 | 2661 | | |
2660 | 2662 | | |
| |||
0 commit comments