Re: [PATCH 1/2] ubi: block: don't use gendisk->first_minor for the idr_alloc return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 30, 2023 at 03:01:05PM +0100, Christoph Hellwig wrote:
> 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@xxxxxx>

Reviewed-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>

> ---
>  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
> 



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux