Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756072AbcKJWbM convert rfc822-to-8bit (ORCPT ); Thu, 10 Nov 2016 17:31:12 -0500 Received: from mga03.intel.com ([134.134.136.65]:53829 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754574AbcKJWbL (ORCPT ); Thu, 10 Nov 2016 17:31:11 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,620,1473145200"; d="scan'208";a="29990888" From: "Dilger, Andreas" To: Colin King CC: James Simmons , Greg Kroah-Hartman , "Hammond, John" , Amitoj Kaur Chawla , "lustre-devel@lists.lustre.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] staging: lustre: lov: Fix signed wrap around when decrementing index 'i' Thread-Topic: [PATCH] staging: lustre: lov: Fix signed wrap around when decrementing index 'i' Thread-Index: AQHSO11tAJM1SSuTp0ah5DfoaLW1n6DTU6IA Date: Thu, 10 Nov 2016 22:31:08 +0000 Message-ID: <1E6549EE-799C-45ED-A9FA-B9B362F51351@intel.com> References: <20161110141910.25095-1-colin.king@canonical.com> In-Reply-To: <20161110141910.25095-1-colin.king@canonical.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.254.106.48] Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1251 Lines: 38 On Nov 10, 2016, at 07:19, Colin King wrote: > > From: Colin Ian King > > Change predecrement compare to post decrement compare to avoid an > unsigned integer wrap-around comparisomn when decrementing in the while > loop. > > Issue found with static analysis with CoverityScan, CID 1375917 Thanks for the patch. Seems this change has gotten a lot of attention, this is the third patch to the list to fix it. My preference is to undo the int->unsigned declaration change, for which James has already submitted a patch. Cheers, Andreas > Signed-off-by: Colin Ian King > --- > drivers/staging/lustre/lustre/lov/lov_ea.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/lustre/lustre/lov/lov_ea.c b/drivers/staging/lustre/lustre/lov/lov_ea.c > index 53db170..399298c 100644 > --- a/drivers/staging/lustre/lustre/lov/lov_ea.c > +++ b/drivers/staging/lustre/lustre/lov/lov_ea.c > @@ -102,7 +102,7 @@ struct lov_stripe_md *lsm_alloc_plain(u16 stripe_count) > return lsm; > > err: > - while (--i >= 0) > + while (i-- > 0) > kmem_cache_free(lov_oinfo_slab, lsm->lsm_oinfo[i]); > kvfree(lsm); > return NULL; > -- > 2.10.2 >