All of
 help / color / mirror / Atom feed
From: Wenchao Hao <>
To: "James E . J . Bottomley" <>,
	"Martin K . Petersen" <>,
	<>, <>
Cc: <>, Wenchao Hao <>,
Subject: [PATCH] scsi: sd: cleanup gendisk if device_add_disk() failed
Date: Thu, 31 Mar 2022 21:10:19 -0400	[thread overview]
Message-ID: <> (raw)

We forget to call blk_cleanup_disk() when device_add_disk() failed.
Which would cause memory leak of gendisk and sched_tags alloced in


Signed-off-by: Wenchao Hao <>
 drivers/scsi/sd.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a390679cf458..4620a1158272 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3475,6 +3475,7 @@ static int sd_probe(struct device *dev)
 	error = device_add_disk(dev, gd, NULL);
 	if (error) {
+		blk_cleanup_disk(gd);
 		goto out;

                 reply	other threads:[~2022-03-31 12:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \

* 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.