From: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
To: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Minchan Kim <minchan@kernel.org>, Nitin Gupta <ngupta@vflare.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] zram: clean up valid_io_request
Date: Thu, 18 Aug 2016 12:25:11 +0900 [thread overview]
Message-ID: <20160818032511.GE500@swordfish> (raw)
In-Reply-To: <1471489681-4027-1-git-send-email-shawn.lin@rock-chips.com>
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
prev parent reply other threads:[~2016-08-18 3:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 3:08 [PATCH] zram: clean up valid_io_request Shawn Lin
2016-08-18 3:25 ` Sergey Senozhatsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160818032511.GE500@swordfish \
--to=sergey.senozhatsky.work@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=ngupta@vflare.org \
--cc=shawn.lin@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.