From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FDFCC433ED for ; Fri, 23 Apr 2021 12:20:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF66F6147D for ; Fri, 23 Apr 2021 12:20:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242497AbhDWMVR (ORCPT ); Fri, 23 Apr 2021 08:21:17 -0400 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:40059 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242383AbhDWMVQ (ORCPT ); Fri, 23 Apr 2021 08:21:16 -0400 Received: from [192.168.1.18] ([86.243.172.93]) by mwinf5d63 with ME id wCLc2400A21Fzsu03CLcf0; Fri, 23 Apr 2021 14:20:38 +0200 X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 23 Apr 2021 14:20:38 +0200 X-ME-IP: 86.243.172.93 Subject: Re: [PATCH] brcmfmac: fix a loop exit condition To: Dan Carpenter , Johannes Berg Cc: Arend van Spriel , Matthias Brugger , Franky Lin , Hante Meuleman , Chi-hsien Lin , Wright Feng , Chung-hsien Hsu , Kalle Valo , Hans deGoede , linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, kernel-janitors@vger.kernel.org References: <427e33af49758c61bc23cf1eedb6dd6964c40296.camel@sipsolutions.net> <20210423121110.GO1981@kadam> From: Christophe JAILLET Message-ID: Date: Fri, 23 Apr 2021 14:20:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210423121110.GO1981@kadam> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Le 23/04/2021 à 14:11, Dan Carpenter a écrit : > On Fri, Apr 23, 2021 at 01:59:36PM +0200, Johannes Berg wrote: >> On Fri, 2021-04-23 at 14:46 +0300, Dan Carpenter wrote: >>> This code is supposed to loop over the whole board_type[] string. The >>> current code kind of works just because ascii values start 97 and the >>> string is likely shorter than that so it will break when we hit the NUL >>> terminator. But really the condition should be "i < len" instead of >>> "i < board_type[i]". >>> >>> Fixes: 29e354ebeeec ("brcmfmac: Transform compatible string for FW loading") >>> Signed-off-by: Dan Carpenter >>> --- >>>  drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c | 2 +- >>>  1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c >>> index a7554265f95f..9b75e396fc50 100644 >>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c >>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c >>> @@ -34,7 +34,7 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type, >>>   len = strlen(tmp) + 1; >>>   board_type = devm_kzalloc(dev, len, GFP_KERNEL); >>>   strscpy(board_type, tmp, len); >>> - for (i = 0; i < board_type[i]; i++) { >>> + for (i = 0; i < len; i++) { >>>   if (board_type[i] == '/') >>>   board_type[i] = '-'; >>>   } >> >> It should probably just use strreplace() though :) > > Good point. I'll send a v2. > and the 2 lines above look like a devm_kstrdup. The (unlikely) malloc failure test is also missing. CJ > regards, > dan carpenter > >