Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752765AbbBYJ0l (ORCPT ); Wed, 25 Feb 2015 04:26:41 -0500 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:48548 "EHLO e06smtp13.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbbBYJ0j (ORCPT ); Wed, 25 Feb 2015 04:26:39 -0500 Date: Wed, 25 Feb 2015 10:26:31 +0100 From: Heiko Carstens To: Ameen Ali Cc: schwidefsky@de.ibm.com, linux390@de.ibm.com, keescook@chromium.org, wsa@the-dreams.de, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dcssblk.c : Array index 'i' is used before limits check. Message-ID: <20150225092631.GA4271@osiris> References: <1424796110-7736-1-git-send-email-ameenali023@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424796110-7736-1-git-send-email-ameenali023@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15022509-0013-0000-0000-000003144117 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1024 Lines: 26 On Tue, Feb 24, 2015 at 06:41:50PM +0200, Ameen Ali wrote: > avoid out-of-bounds-read by checking count before indexing. > > Signed-off-by : Ameen Ali > --- > drivers/s390/block/dcssblk.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c > index 96128cb..da21281 100644 > --- a/drivers/s390/block/dcssblk.c > +++ b/drivers/s390/block/dcssblk.c > @@ -547,7 +547,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char > * parse input > */ > num_of_segments = 0; > - for (i = 0; ((buf[i] != '\0') && (buf[i] != '\n') && i < count); i++) { > + for (i = 0; (i < count && (buf[i] != '\0') && (buf[i] != '\n')); i++) { Applied, thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/