Re: [PATCH] tcmu_rbd_open() detect/fail if block_size is zero

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

 



On 05/04/2017 03:17 PM, David Butterfield wrote:
> Modify the check of the return from tcmu_get_attribute("hw_block_size")
> to fail if the returned value is zero, so as to avoid dividing by it
> a few lines later.
> 
> Signed-off-by: David Butterfield <dab21774@xxxxxxxxx>
> ---
>  rbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rbd.c b/rbd.c
> index 852338d..c8019b5 100644
> --- a/rbd.c
> +++ b/rbd.c
> @@ -411,7 +411,7 @@ static int tcmu_rbd_open(struct tcmu_device *dev)
>  	config += 1; /* get past '/' */
>  
>  	block_size = tcmu_get_attribute(dev, "hw_block_size");
> -	if (block_size < 0) {
> +	if (block_size <= 0) {
>  		tcmu_dev_err(dev, "Could not get hw_block_size\n");
>  		ret = -EINVAL;
>  		goto free_state;
> 

Are you able to set the hw_block_size to 0? I am asking because it looks
like there are a couple checks in the kernel so this should not happen.
Is this with your our of tree use?

Patch seems harmless. Merged. Thanks.
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux