Skip to contentSkip to conversation

/fs/partition/check.c: fix return value warning

PATCH In review Abdel Benamrouche 3 participants 3 messages May 10, 2008 – May 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 /fs/partition/check.c: fix return value warning

fs/partitions/check.c:381: warning: ignoring return value of ‘device_add’,
declared with attribute warn_unused_result

---
:100644 100644 6149e4b... 7a87fad... M fs/partitions/check.c

 fs/partitions/check.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
fs/partitions/check.c +7 -1
index 6149e4b..7a87fad 100644
@@ -378,7 +378,13 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
 
 	/* delay uevent until 'holders' subdir is created */
 	p->dev.uevent_suppress = 1;
-	device_add(&p->dev);
+	if (device_add(&p->dev)) {
+		put_device(&p->dev);
+		free_part_stats(p);
+		kfree(p);
+		return;
+	}
+
 	partition_sysfs_add_subdir(p);
 	p->dev.uevent_suppress = 0;
 	if (flags & ADDPART_FLAG_WHOLEDISK)
Signature · 1 line
1.5.4.3
#1 lore raw
Quoted 18 lines · On Sat, 10 May 2008 13:40:53 +0200 Abdel Benamrouche <[email protected]> wrote:

fs/partitions/check.c:381: warning: ignoring return value of ___device_add___,
declared with attribute warn_unused_result

---
:100644 100644 6149e4b... 7a87fad... M fs/partitions/check.c

 fs/partitions/check.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
fs/partitions/check.c +0 -1
index 6149e4b..7a87fad 100644
@@ -378,7 +378,13 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
 
 	/* delay uevent until 'holders' subdir is created */
 	p->dev.uevent_suppress = 1;
-	device_add(&p->dev);

fs/partitions/check.c void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, · line 390

Quoted 10 lines
fs/partitions/check.c +7 -0
+	if (device_add(&p->dev)) {
+		put_device(&p->dev);
+		free_part_stats(p);
+		kfree(p);
+		return;
+	}
+
 	partition_sysfs_add_subdir(p);
 	p->dev.uevent_suppress = 0;
 	if (flags & ADDPART_FLAG_WHOLEDISK)

We should go further than this. add_partition() just drops the error on the floor. It should be propagated back to callers, and callers should be modified to handle it appropriately.

Presumably we should also handle a device_create_file() failure as well
- that is presently being silently ignored.

#2 lore raw

Hi Abdel,

2008/5/13 Andrew Morton <[email protected]>:

Quoted 36 lines
Quoted 18 lines · On Sat, 10 May 2008 13:40:53 +0200 Abdel Benamrouche <[email protected]> wrote:

fs/partitions/check.c:381: warning: ignoring return value of ___device_add___,
declared with attribute warn_unused_result

---
:100644 100644 6149e4b... 7a87fad... M fs/partitions/check.c

 fs/partitions/check.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
fs/partitions/check.c +0 -1
index 6149e4b..7a87fad 100644
@@ -378,7 +378,13 @@ void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len,
 
      /* delay uevent until 'holders' subdir is created */
      p->dev.uevent_suppress = 1;
-     device_add(&p->dev);

fs/partitions/check.c void add_partition(struct gendisk *disk, int part, sector_t start, sector_t len, · line 390

Quoted 10 lines
fs/partitions/check.c +7 -0
+     if (device_add(&p->dev)) {
+             put_device(&p->dev);
+             free_part_stats(p);
+             kfree(p);
+             return;
+     }
+
      partition_sysfs_add_subdir(p);
      p->dev.uevent_suppress = 0;
      if (flags & ADDPART_FLAG_WHOLEDISK)

We should go further than this. add_partition() just drops the error on the floor. It should be propagated back to callers, and callers should be modified to handle it appropriately.

Quoted 3 lines

Presumably we should also handle a device_create_file() failure as well
- that is presently being silently ignored.

Given these comments from Andrew, I'm not adding this patch to the Trivial tree. Please address Andrews comments and re-submit - at which point I doubt it'll be suitable for trivial, so please try to get it merged via other maintainers.

Signature · 3 lines
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html