[PATCH 1/2] ubi: block: don't use gendisk->first_minor for the idr_alloc return value
Richard Weinberger
richard at nod.at
Mon Oct 30 07:46:25 PDT 2023
----- Ursprüngliche Mail -----
> 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 at 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;
Super minor nit, redundant space.
Acked-by: Richard Weinberger <richard at nod.at>
Thanks,
//richard
More information about the linux-mtd
mailing list