All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ubi: block: don't use gendisk->first_minor for the idr_alloc return value
@ 2023-10-30 14:01 ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2023-10-30 14:01 UTC (permalink / raw)
  To: axboe, richard, miquel.raynal, vigneshr
  Cc: linux-block, linux-mtd, zhongjinghua, yukuai1

idr_alloc returns an int that is either a negative errno, or the
identifier actually allocated.  Use signed integer ret variable to
catch the return value and only assign it to gd->first_minor to prepare
for marking the first_minor field in the gendisk structure as unsigned.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/mtd/ubi/block.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index 437c5b83ffe513..51d00b518d3197 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -402,13 +402,14 @@ int ubiblock_create(struct ubi_volume_info *vi)
 	gd->fops = &ubiblock_ops;
 	gd->major = ubiblock_major;
 	gd->minors = 1;
-	gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
-	if (gd->first_minor < 0) {
+	ret = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL);
+	if (ret < 0) {
 		dev_err(disk_to_dev(gd),
 			"block: dynamic minor allocation failed");
 		ret = -ENODEV;
 		goto out_cleanup_disk;
 	}
+	gd->first_minor  = ret;
 	gd->flags |= GENHD_FL_NO_PART;
 	gd->private_data = dev;
 	sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
-- 
2.39.2


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

end of thread, other threads:[~2023-10-30 14:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-30 14:01 [PATCH 1/2] ubi: block: don't use gendisk->first_minor for the idr_alloc return value Christoph Hellwig
2023-10-30 14:01 ` Christoph Hellwig
2023-10-30 14:01 ` [PATCH 2/2] block: dev_t components are unsigned Christoph Hellwig
2023-10-30 14:01   ` Christoph Hellwig
2023-10-30 14:05 ` [PATCH 1/2] ubi: block: don't use gendisk->first_minor for the idr_alloc return value Daniel Golle
2023-10-30 14:05   ` Daniel Golle
2023-10-30 14:46 ` Richard Weinberger
2023-10-30 14:46   ` Richard Weinberger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.