check return value of call to device_add()
PATCH 1/1 check return value of call to device_add()
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 <[email protected]>
--- fs/partitions/check.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
fs/partitions/check.c +9 -2
@@ -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 )
Signature · 1 line
1.5.4.5