From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753873AbcHRDZb (ORCPT ); Wed, 17 Aug 2016 23:25:31 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:36371 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753580AbcHRDZa (ORCPT ); Wed, 17 Aug 2016 23:25:30 -0400 Date: Thu, 18 Aug 2016 12:25:11 +0900 From: Sergey Senozhatsky To: Shawn Lin Cc: Minchan Kim , Nitin Gupta , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Andrew Morton Subject: Re: [PATCH] zram: clean up valid_io_request Message-ID: <20160818032511.GE500@swordfish> References: <1471489681-4027-1-git-send-email-shawn.lin@rock-chips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1471489681-4027-1-git-send-email-shawn.lin@rock-chips.com> User-Agent: Mutt/1.6.2 (2016-07-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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