Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752953AbbBXT5J (ORCPT ); Tue, 24 Feb 2015 14:57:09 -0500 Received: from mail-la0-f50.google.com ([209.85.215.50]:33839 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752899AbbBXT5H (ORCPT ); Tue, 24 Feb 2015 14:57:07 -0500 Message-ID: <54ECD78F.7040607@cogentembedded.com> Date: Tue, 24 Feb 2015 22:57:03 +0300 From: Sergei Shtylyov Organization: Cogent Embedded User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Ameen Ali , kas@fi.muni.cz CC: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] cosa.c : Array index 'i' is used before limits check. References: <1424807546-10013-1-git-send-email-ameenali023@gmail.com> In-Reply-To: <1424807546-10013-1-git-send-email-ameenali023@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1020 Lines: 34 Hello. On 02/24/2015 10:52 PM, Ameen Ali wrote: > avoid out-of-bounds-read by checking count before indexing. > Signed-off-by: Ameen Ali > --- > drivers/net/wan/cosa.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c > index 83c39e2..5252e21 100644 > --- a/drivers/net/wan/cosa.c > +++ b/drivers/net/wan/cosa.c > @@ -376,7 +376,7 @@ static int __init cosa_init(void) > } > for (i=0; i cosa_cards[i].num = -1; > - for (i=0; io[i] != 0 && i < MAX_CARDS; i++) > + for (i=0; (i < MAX_CARDS) && (io[i] != 0) ; i++) Parens you've added aren't necessary. I suggest to add spaces after and before = in the first expression. [...] WBR, Sergei -- 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/