linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Fleming <mjf@gentoo.org>
To: linux-fsdevel@vger.kernel.org
Cc: Matt Fleming <mjf@gentoo.org>
Subject: [PATCH] check return value of call to device_add()
Date: Fri, 18 Jul 2008 22:57:15 +0100	[thread overview]
Message-ID: <1216418235-7349-1-git-send-email-mjf@gentoo.org> (raw)

Silence a warning by checking the return value of device_add() and
fail gracefully if the return value indicates an error.

Signed-off-by: Matt Fleming <mjf@gentoo.org>
---
 fs/partitions/check.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 6149e4b..d222758 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -374,11 +374,18 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
 	p->dev.class = &block_class;
 	p->dev.type = &part_type;
 	p->dev.parent = &disk->dev;
-	disk->part[part-1] = p;
 
 	/* delay uevent until 'holders' subdir is created */
 	p->dev.uevent_suppress = 1;
-	device_add(&p->dev);
+
+	err = device_add(&p->dev);
+	if (err) {
+		printk(KERN_WARN "%s: device_add failed\n", __func__);
+		free(p);
+		return;
+	}
+
+	disk->part[part-1] = p;
 	partition_sysfs_add_subdir(p);
 	p->dev.uevent_suppress = 0;
 	if (flags & ADDPART_FLAG_WHOLEDISK)
-- 
1.5.4.5


                 reply	other threads:[~2008-07-18 22:03 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:
  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=1216418235-7349-1-git-send-email-mjf@gentoo.org \
    --to=mjf@gentoo.org \
    --cc=linux-fsdevel@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;
as well as URLs for NNTP newsgroup(s).