From: Alfredo Cruz <alfredo.carlon@gmail.com>
To: axboe@kernel.dk, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: Alfredo Cruz <alfredo.carlon@gmail.com>
Subject: [PATCH] block: add put_device() call when device_add() fails in device_add_disk()
Date: Wed, 21 Feb 2024 23:01:41 +0100 [thread overview]
Message-ID: <20240221220141.32316-1-alfredo.carlon@gmail.com> (raw)
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@gmail.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
next reply other threads:[~2024-02-21 22:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-21 22:01 Alfredo Cruz [this message]
2024-02-22 9:22 ` Yu Kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240221220141.32316-1-alfredo.carlon@gmail.com \
--to=alfredo.carlon@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®