Skip to contentSkip to conversation

block: switch to pr_warn() in __device_add_disk()

PATCH In review Rustam Kovhaev 2 participants 3 messages Oct 11, 2020 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: switch to pr_warn() in __device_add_disk()

syzbot triggered a warning while fuzzing with failslab fault injection enabled
let's convert WARN_ON() to pr_warn()

---
 block/genhd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
block/genhd.c +2 -1
index 99c64641c314..be9ce35cf0fe 100644
@@ -822,7 +822,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
 		/* Register BDI before referencing it from bdev */
 		dev->devt = devt;
 		ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
-		WARN_ON(ret);
+		if (ret)
+			pr_warn("%s: failed to register backing dev info\n", disk->disk_name);
 		bdi_set_owner(bdi, dev);
 		blk_register_region(disk_devt(disk), disk->minors, NULL,
 				    exact_match, exact_lock, disk);
Signature · 1 line
2.28.0
#1 lore raw
Quoted 17 lines · Rustam Kovhaev

syzbot triggered a warning while fuzzing with failslab fault injection enabled
let's convert WARN_ON() to pr_warn()

---
  block/genhd.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
block/genhd.c +0 -0
index 99c64641c314..be9ce35cf0fe 100644

block/genhd.c static void __device_add_disk(struct device *parent, struct gendisk *disk, · line 829

Quoted 9 lines
block/genhd.c +2 -1
@@ -822,7 +822,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
  		/* Register BDI before referencing it from bdev */
  		dev->devt = devt;
  		ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
-		WARN_ON(ret);
+		if (ret)
+			pr_warn("%s: failed to register backing dev info\n", disk->disk_name);
  		bdi_set_owner(bdi, dev);
  		blk_register_region(disk_devt(disk), disk->minors, NULL,
  				    exact_match, exact_lock, disk);

Please, don't. Where is the point in continuing here?
I'd rather have it fixed up properly, either by having a return value to __device_add_disk() or by allowing the caller to check (eg by checking GENHD_FL_UP) if the call succeeded.

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                Kernel Storage Architect
[email protected]                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
#2 lore raw
Quoted 23 lines · Hannes Reinecke
Quoted 22 lines · Rustam Kovhaev

syzbot triggered a warning while fuzzing with failslab fault injection enabled
let's convert WARN_ON() to pr_warn()

---
  block/genhd.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
block/genhd.c +2 -1
index 99c64641c314..be9ce35cf0fe 100644
@@ -822,7 +822,8 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk,
  		/* Register BDI before referencing it from bdev */
  		dev->devt = devt;
  		ret = bdi_register(bdi, "%u:%u", MAJOR(devt), MINOR(devt));
-		WARN_ON(ret);
+		if (ret)
+			pr_warn("%s: failed to register backing dev info\n", disk->disk_name);
Quoted 8 lines

block/genhd.c static void __device_add_disk(struct device *parent, struct gendisk *disk, · line 829

Quoted 4 lines
block/genhd.c +0 -0
  		bdi_set_owner(bdi, dev);
  		blk_register_region(disk_devt(disk), disk->minors, NULL,
  				    exact_match, exact_lock, disk);

Please, don't. Where is the point in continuing here?
I'd rather have it fixed up properly, either by having a return value to __device_add_disk() or by allowing the caller to check (eg by checking GENHD_FL_UP) if the call succeeded.

thank you for the review, it makes sense.