From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Fleming Subject: [PATCH] check return value of call to device_add() Date: Fri, 18 Jul 2008 22:57:15 +0100 Message-ID: <1216418235-7349-1-git-send-email-mjf@gentoo.org> Cc: Matt Fleming To: linux-fsdevel@vger.kernel.org Return-path: Received: from 82-38-64-26.cable.ubr06.brad.blueyonder.co.uk ([82.38.64.26]:63365 "EHLO arkanian.console-pimps.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754093AbYGRWD0 (ORCPT ); Fri, 18 Jul 2008 18:03:26 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- 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