Skip to content
Snippets Groups Projects
Commit 0df11fa8 authored by Ma Ke's avatar Ma Ke Committed by Greg Kroah-Hartman
Browse files

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 <stable@kernel.org>
Fixes: 9f8b17e6 ("USB: make usbdevices export their device nodes instead of using a separate class")
Signed-off-by: default avatarMa Ke <make_ruc2021@163.com>
Reviewed-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20241218071346.2973980-1-make_ruc2021@163.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 862a9c0f
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment