Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3224685imm; Sun, 7 Oct 2018 23:38:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV63IeHiJb8WrF7P5Ii9uOKkYzU5tQG8knrNkYDetuFtX1gQmkQfw8zDRQvHBrP7uLFbVefI7 X-Received: by 2002:a65:65c6:: with SMTP id y6-v6mr19503423pgv.233.1538980708830; Sun, 07 Oct 2018 23:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538980708; cv=none; d=google.com; s=arc-20160816; b=c32fWuMUjGZ9zvBqapCFEdnspLBmTddgTw90aNDSIBNFGcnwj6v9n71RjXWQnKNSoI FqrseHkPLV49v8HFjC3H2eN3AE7/DPGslQw3wTeGUFC0zATviT+WTLXpPl0gzK6qQ2p0 x3hMauEDTChBS7guL6fgWnAz0R+UM8yGJ3x41N3OOVox34osLPFWiW4y77dNth4Hvb8N CtBDzgiOCt7gO0t0jbksDFU2a84shQSMxGheMyCZXru2SB8BB63G4M1H+PHNDPiS1QpQ mY4Fu+9yCzjIze8bbQAKKDeLA7XsdpyT+Q5LAm5g53kMKbLE5jZptCbTFxwUMaoeqG3A FC7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature; bh=Cp9zqtMDKp9Rk+oPCMB3kD/KX+eD6YlKLX1IzqISO3Y=; b=DkOiZs04GMzf0pF4d39pjSypaDtlr/TeWjcZXJmsCxmJEQVir8d24q9ORoS3a4Almm d937OKP7HJrVeIfDnRwQqr9ciAYZYrpOB6vgW7alltZy4bYvhrXvwXuX12nmimz5G5JS 8HcIHNjR6cS1kcmKPRUBHheko9IRKp+d9G7zfXco68QaHOAQHQdfl0cYvrEqNorXm8NC UWk6Gs7fF9an5GpXvL34dcrlOjwI1rVl1j6HbGto1CkYZvTZNB8DMGp7TYHUFjKSCRxl s9jE/VxA6fG0zkTAEiLgxNiLRuHNfeFl7a2K4ZA34VfAgRKCkcrP0HnPAG4irl3pX6cq IO9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jmSJ5rL8; dkim=pass header.i=@codeaurora.org header.s=default header.b=jmSJ5rL8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a15-v6si17181825pfn.248.2018.10.07.23.38.13; Sun, 07 Oct 2018 23:38:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=jmSJ5rL8; dkim=pass header.i=@codeaurora.org header.s=default header.b=jmSJ5rL8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726810AbeJHNsQ (ORCPT + 99 others); Mon, 8 Oct 2018 09:48:16 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:53856 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725857AbeJHNsQ (ORCPT ); Mon, 8 Oct 2018 09:48:16 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E723060B7A; Mon, 8 Oct 2018 06:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538980686; bh=bLa+d8B/HbsCXOz0+asoAEMIjDjycZnp74unzUQET8E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jmSJ5rL8ZbEZ0xD+u1/uxhh8SF1CFRYkJgc26RQu42+jAWxtuGjmj8Ngrt3Ylf23F Xb4fhqAl2O/U3D9Yp2/3U/y0GW95iWHx9HXr+uutl23cVKk2O910Ik9qGe6N8/fReI Tl7UgKb67aZE5BwkKwFPc0Ljgp3KHodTo2rkx9rs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 20D4E60769; Mon, 8 Oct 2018 06:38:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538980686; bh=bLa+d8B/HbsCXOz0+asoAEMIjDjycZnp74unzUQET8E=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jmSJ5rL8ZbEZ0xD+u1/uxhh8SF1CFRYkJgc26RQu42+jAWxtuGjmj8Ngrt3Ylf23F Xb4fhqAl2O/U3D9Yp2/3U/y0GW95iWHx9HXr+uutl23cVKk2O910Ik9qGe6N8/fReI Tl7UgKb67aZE5BwkKwFPc0Ljgp3KHodTo2rkx9rs= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 08 Oct 2018 12:08:06 +0530 From: Anilkumar Kolli To: "Gustavo A. R. Silva" Cc: Ben Greear , Kalle Valo , "David S. Miller" , ath10k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-wireless-owner@vger.kernel.org Subject: Re: [PATCH] ath10k: htt_rx: Fix signedness bug in ath10k_update_per_peer_tx_stats In-Reply-To: References: <20181005184245.GA11700@embeddedor.com> <3a55bec6-d20d-f500-e741-b228a86b7117@candelatech.com> Message-ID: X-Sender: akolli@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-10-06 00:45, Gustavo A. R. Silva wrote: > On 10/5/18 9:14 PM, Gustavo A. R. Silva wrote: >> >> >> On 10/5/18 9:09 PM, Ben Greear wrote: >>> On 10/05/2018 11:42 AM, Gustavo A. R. Silva wrote: >>>> Currently, the error handling for the call to function >>>> ath10k_get_legacy_rate_idx() doesn't work because >>>> *rate_idx* is of type u8 (8 bits, unsigned), which >>>> makes it impossible for it to hold a value less >>>> than 0. >>>> >>>> Fix this by changing the type of variable *rate_idx* >>>> to s8 (8 bits, signed). >>> >>> There are more than 127 rates, are you sure this is doing >>> what you want? >>> >> >> Based on the following function, rate_idx can only hold values from 0 >> to 11 >> > > ... and of course -EINVAL too > >> static inline int ath10k_get_legacy_rate_idx(struct ath10k *ar, u8 >> rate) >> { >> static const u8 legacy_rates[] = {1, 2, 5, 11, 6, 9, 12, >> 18, 24, 36, 48, 54}; >> int i; >> >> for (i = 0; i < ARRAY_SIZE(legacy_rates); i++) { >> if (rate == legacy_rates[i]) >> return i; >> } >> >> ath10k_warn(ar, "Invalid legacy rate %hhd peer stats", rate); >> return -EINVAL; >> } >> >> Thanks >> -- >> Gustavo >> >>> Thanks, >>> Ben >>> >>>> >>>> Addresses-Coverity-ID: 1473914 ("Unsigned compared against 0") >>>> Fixes: 0189dbd71cbd ("ath10k: get the legacy rate index to update >>>> the txrate table") >>>> Signed-off-by: Gustavo A. R. Silva >>>> --- >>>>  drivers/net/wireless/ath/ath10k/htt_rx.c | 3 ++- >>>>  1 file changed, 2 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c >>>> b/drivers/net/wireless/ath/ath10k/htt_rx.c >>>> index f240525..edd0e74 100644 >>>> --- a/drivers/net/wireless/ath/ath10k/htt_rx.c >>>> +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c >>>> @@ -2753,7 +2753,8 @@ ath10k_update_per_peer_tx_stats(struct ath10k >>>> *ar, >>>>                  struct ath10k_per_peer_tx_stats *peer_stats) >>>>  { >>>>      struct ath10k_sta *arsta = (struct ath10k_sta *)sta->drv_priv; >>>> -    u8 rate = 0, rate_idx = 0, sgi; >>>> +    u8 rate = 0, sgi; >>>> +    s8 rate_idx = 0; >>>>      struct rate_info txrate; >>>> >>>>      lockdep_assert_held(&ar->data_lock); >>>> >>> >>> I have sent a patch to address this, https://patchwork.kernel.org/patch/10611943/ Thanks Anil.