Commit 0df11fa
usb: fix reference leak in usb_new_device()
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 <[email protected]>
Fixes: 9f8b17e ("USB: make usbdevices export their device nodes instead of using a separate class")
Signed-off-by: Ma Ke <[email protected]>
Reviewed-by: Alan Stern <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>1 parent 862a9c0 commit 0df11fa
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2663 | 2663 | | |
2664 | 2664 | | |
2665 | 2665 | | |
2666 | | - | |
| 2666 | + | |
2667 | 2667 | | |
2668 | 2668 | | |
2669 | 2669 | | |
2670 | 2670 | | |
2671 | 2671 | | |
2672 | | - | |
| 2672 | + | |
2673 | 2673 | | |
2674 | 2674 | | |
2675 | 2675 | | |
| |||
2683 | 2683 | | |
2684 | 2684 | | |
2685 | 2685 | | |
| 2686 | + | |
| 2687 | + | |
2686 | 2688 | | |
2687 | 2689 | | |
2688 | 2690 | | |
| |||
0 commit comments