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]
Date: Wed, 21 Feb 2024 23:01:41 +0100
From: Alfredo Cruz <alfredo.carlon@...il.com>
To: axboe@...nel.dk,
	linux-block@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: Alfredo Cruz <alfredo.carlon@...il.com>
Subject: [PATCH] block: add put_device() call when device_add() fails in device_add_disk()

When device_add() fails, put_device() should called for cleanup.
Added this call before the jump to out_free_ext_minor to not
interfere with device_del() on error paths where deivce_add() succeeded

Signed-off-by: Alfredo Cruz <alfredo.carlon@...il.com>
---
 block/genhd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/genhd.c b/block/genhd.c
index d74fb5b4ae68..5a231fb075bd 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -456,8 +456,10 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
 	if (!(disk->flags & GENHD_FL_HIDDEN))
 		ddev->devt = MKDEV(disk->major, disk->first_minor);
 	ret = device_add(ddev);
-	if (ret)
+	if (ret) {
+		put_device(ddev);
 		goto out_free_ext_minor;
+	}
 
 	ret = disk_alloc_events(disk);
 	if (ret)
-- 
2.43.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ