lkml.org 
[lkml]   [2016]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] zram: clean up valid_io_request
Hi,

On (08/18/16 11:08), Shawn Lin wrote:
[..]
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 04365b1..1094e95 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -120,15 +120,15 @@ static inline bool valid_io_request(struct zram *zram,
> u64 end, bound;
>
> /* unaligned request */
> - if (unlikely(start & (ZRAM_SECTOR_PER_LOGICAL_BLOCK - 1)))
> + if (unlikely(!IS_ALIGNED(start, ZRAM_SECTOR_PER_LOGICAL_BLOCK)))
> return false;
> - if (unlikely(size & (ZRAM_LOGICAL_BLOCK_SIZE - 1)))
> + if (unlikely(!IS_ALIGNED(size, ZRAM_LOGICAL_BLOCK_SIZE)))
> return false;

ok.

> end = start + (size >> SECTOR_SHIFT);
> bound = zram->disksize >> SECTOR_SHIFT;
> /* out of range range */
> - if (unlikely(start >= bound || end > bound || start > end))
> + if (unlikely(start >= bound || end > bound))
> return false;

why did you drop `start > end'? what if `start + (size >> SECTOR_SHIFT)'
overflows and `start' becomes greater than `end'?

-ss

\
 
 \ /
  Last update: 2016-09-17 09:57    [W:0.027 / U:0.504 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site