Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933626AbcKJOTb (ORCPT ); Thu, 10 Nov 2016 09:19:31 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:50087 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933472AbcKJOTa (ORCPT ); Thu, 10 Nov 2016 09:19:30 -0500 From: Colin King To: Andreas Dilger , James Simmons , Greg Kroah-Hartman , "John L . Hammond" , Amitoj Kaur Chawla , lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] staging: lustre: lov: Fix signed wrap around when decrementing index 'i' Date: Thu, 10 Nov 2016 14:19:10 +0000 Message-Id: <20161110141910.25095-1-colin.king@canonical.com> X-Mailer: git-send-email 2.10.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 879 Lines: 28 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 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