mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs/partitions/check.c: add error handling for kobject_add
@ 2007-10-22  5:22 Borislav Petkov
       [not found] ` <20071023233900.7e683516.akpm@linux-foundation.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2007-10-22  5:22 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton

From: Borislav Petkov <bbpetkov@yahoo.de>

Add error handling to the kobject_add()-call and signal (the even highly
unlikely) error condition.

Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>

--
diff --git a/fs/partitions/check.c b/fs/partitions/check.c
index 722e12e..5490e33 100644
--- a/fs/partitions/check.c
+++ b/fs/partitions/check.c
@@ -371,11 +371,12 @@ void delete_partition(struct gendisk *disk, int part)
 void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, int flags)
 {
 	struct hd_struct *p;
+	int err = -EINVAL;
 
 	p = kzalloc(sizeof(*p), GFP_KERNEL);
 	if (!p)
 		return;
-	
+
 	p->start_sect = start;
 	p->nr_sects = len;
 	p->partno = part;
@@ -390,7 +391,13 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
 	p->kobj.parent = &disk->kobj;
 	p->kobj.ktype = &ktype_part;
 	kobject_init(&p->kobj);
-	kobject_add(&p->kobj);
+
+	err = kobject_add(&p->kobj);
+	if (err) {
+		pr_err("%s: Error adding %s to sysfs\n", __FUNCTION__,
+				kobject_name(&p->kobj));
+	}
+
 	if (!disk->part_uevent_suppress)
 		kobject_uevent(&p->kobj, KOBJ_ADD);
 	sysfs_create_link(&p->kobj, &block_subsys.kobj, "subsystem");
-- 
Regards/Gruß,
    Boris.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-24  9:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-22  5:22 [PATCH] fs/partitions/check.c: add error handling for kobject_add Borislav Petkov
     [not found] ` <20071023233900.7e683516.akpm@linux-foundation.org>
2007-10-24  9:32   ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®