[PATCH] check return value of call to device_add()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux