lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241217035353.2891942-1-make_ruc2021@163.com>
Date: Tue, 17 Dec 2024 11:53:52 +0800
From: Ma Ke <make_ruc2021@....com>
To: gregkh@...uxfoundation.org,
	stern@...land.harvard.edu,
	mka@...omium.org,
	christophe.jaillet@...adoo.fr,
	quic_ugoswami@...cinc.com,
	oneukum@...e.com,
	stanley_chang@...ltek.com,
	javier.carrasco@...fvision.net
Cc: linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Ma Ke <make_ruc2021@....com>,
	stable@...r.kernel.org
Subject: [PATCH] usb: fix reference leak in usb_new_device()

When device_add(&udev->dev) failed, calling put_device() to explicitly
release udev->dev. Otherwise, it could cause double free problem.

Found by code review.

Cc: stable@...r.kernel.org
Fixes: 9f8b17e643fe ("USB: make usbdevices export their device nodes instead of using a separate class")
Signed-off-by: Ma Ke <make_ruc2021@....com>
---
 drivers/usb/core/hub.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 4b93c0bd1d4b..05b778d2ad63 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2651,6 +2651,7 @@ int usb_new_device(struct usb_device *udev)
 	err = device_add(&udev->dev);
 	if (err) {
 		dev_err(&udev->dev, "can't device_add, error %d\n", err);
+		put_device(&udev->dev);
 		goto fail;
 	}
 
@@ -2683,6 +2684,9 @@ int usb_new_device(struct usb_device *udev)
 	pm_runtime_put_sync_autosuspend(&udev->dev);
 	return err;
 
+out_del_dev:
+	device_del(&udev->dev);
+	put_device(&udev->dev);
 fail:
 	usb_set_device_state(udev, USB_STATE_NOTATTACHED);
 	pm_runtime_disable(&udev->dev);
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ