* [PATCH] check return value of call to device_add()
@ 2008-07-18 21:57 Matt Fleming
0 siblings, 0 replies; only message in thread
From: Matt Fleming @ 2008-07-18 21:57 UTC (permalink / raw)
To: linux-fsdevel; +Cc: Matt Fleming
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2008-07-18 22:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-18 21:57 [PATCH] check return value of call to device_add() Matt Fleming
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).