Re: [PATCH 5/6] dm-switch: Remove unnecessary condition in conditional

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

 




On Wed, 28 Oct 2015, Tomohiro Kusumi wrote:

> It's always (sctx->nr_regions == nr_regions) considering
> the assignment right before this conditional, and this
> function is only used by .ctr.

The variable sctx->nr_regions has type unsigned long and the variable 
nr_regions has type sector_t.

Thus the variables may be different when overflow happens.

It could be changed to "if (nr_regions >= ULONG_MAX)".

Mikulas

> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@xxxxxxxxx>
> ---
>  drivers/md/dm-switch.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c
> index 50fca46..372ec34 100644
> --- a/drivers/md/dm-switch.c
> +++ b/drivers/md/dm-switch.c
> @@ -100,7 +100,7 @@ static int alloc_region_table(struct dm_target *ti, unsigned nr_paths)
>  		nr_regions++;
>  
>  	sctx->nr_regions = nr_regions;
> -	if (sctx->nr_regions != nr_regions || sctx->nr_regions >= ULONG_MAX) {
> +	if (sctx->nr_regions >= ULONG_MAX) {
>  		ti->error = "Region table too large";
>  		return -EINVAL;
>  	}
> -- 
> 1.7.1
> 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux