Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp396282pxm; Tue, 22 Feb 2022 13:14:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOAsV5xUIWEl1Ga+3tqTx2JravX9byrA60J1pyTNvob/CxwfWCOs4TBD4OJdvFTYDe07x7 X-Received: by 2002:a17:907:1dc4:b0:6a8:4a41:fed9 with SMTP id og4-20020a1709071dc400b006a84a41fed9mr20516399ejc.115.1645564445251; Tue, 22 Feb 2022 13:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645564445; cv=none; d=google.com; s=arc-20160816; b=zesRGVVv4LRwjyNCKOabaouGggkSS0YP/8BUoQvQmfmO6O6kGN0Fb+G5b27atUTlGM +JdPxkKJqTpthUT8gP0V7xG2mVG5hRYHGDa1IW8iqD0JjxTGIW9SPNkxMdLZWMUHjwgD 6t4T4wy00xXy2aWu0bd2qrAg/9uf25Fv5Pudxmb4i7uENTxpxcuGrNPdlR1v+NCt//Js K/5lm5JNqPhUVn2PiC8CyjIcAptbEwISSz3SH8dfwryUSAt7KzTz+Ex9qyiIOMxZLdC+ CxAFO+CV6j7uLuabaIa3dXjE1JLW20F7efZA/MhoUzy8qU0b+UW3zVzE0879mdIGF6Z0 oXdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=RGf7UYwot34BV0nM/N1ZCdlnYIzevn7iRlhfia03PL0=; b=pZSXx8OsmKvMDXndujnNX3Lrgrb3jKW1SXXj02JnSVCbfY1i/HK4fJdpBVo29oZo0n hBGmyuVLc2KrC3/rzDCcv+M3IQhGL/vpNz7Jz2rMlluI2Ta7BUc73HldYwXYu7BYe+Fc sJOEg9D0EsCEO/KuKiYs0g6SMDbauk1/bI8QQCRILWhThXXHxplCKI7LlUujJAU4EXRU iulWeit6iVTcNFxrCyul/f1PUKNPeoEvyqglhXck3RHaS3hyu8cp2Pldwj4zSy9nWvt/ ZN6lx6QaO575t1zs1pnDgs47Hn3On2FMof0BOQsXQgQu49oCsy1trJxUGFrgs0xuahww vxYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=EBxfewEz; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck19si10623208ejb.1.2022.02.22.13.13.38; Tue, 22 Feb 2022 13:14:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=EBxfewEz; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235703AbiBVUxE (ORCPT + 72 others); Tue, 22 Feb 2022 15:53:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235525AbiBVUwy (ORCPT ); Tue, 22 Feb 2022 15:52:54 -0500 Received: from alexa-out-sd-02.qualcomm.com (alexa-out-sd-02.qualcomm.com [199.106.114.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3A2A27B3 for ; Tue, 22 Feb 2022 12:52:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1645563149; x=1677099149; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=RGf7UYwot34BV0nM/N1ZCdlnYIzevn7iRlhfia03PL0=; b=EBxfewEzbmI98CI2JhmMqMtMo0dZKReb2emRkjYXv2cZTcBX7H3v+zeZ HzVniN+mshAj5gMdWt/1Pi4u7WgcS5z6GQxntQfOvaMym7Qynq7Wdk4gX 7twwCRgIlohM0u0V6CMFSYwqwvQXdzEIEDKinYihjGmnxsnMmM8boNUdw c=; Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-02.qualcomm.com with ESMTP; 22 Feb 2022 12:52:28 -0800 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg05-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2022 12:52:28 -0800 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 22 Feb 2022 12:52:28 -0800 Received: from [10.48.243.226] (10.49.16.6) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.15; Tue, 22 Feb 2022 12:52:27 -0800 Message-ID: Date: Tue, 22 Feb 2022 12:52:27 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v2] ath10k: fix pointer arithmetic error in trace call Content-Language: en-US To: Francesco Magliocca , CC: , , References: <20220221122638.7971-1-franciman12@gmail.com> From: Jeff Johnson In-Reply-To: <20220221122638.7971-1-franciman12@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 2/21/2022 4:26 AM, Francesco Magliocca wrote: > Reading through the commit history, it looks like > there is no special need why we must skip the first 4 bytes > in this trace call: > > trace_ath10k_htt_rx_desc(ar, (void*)rx_desc + sizeof(u32), > hw->rx_desc_ops->rx_desc_size - sizeof(u32)); > > found in the function ath10k_htt_rx_amsdu_pop in the file htt_rx.c > > i think the original author > (who is also the one who added rx_desc tracing capabilities > in a0883cf7e75a) just wanted to trace the rx_desc contents, > ignoring the fw_rx_desc_base info field > (which is the part being skipped over). > But the trace_ath10k_htt_rx_desc later added > don't care about skipping it, so it may be good > to uniform this call to the others in the file. > But this would change the output of the trace and > thus it may be a problem for tools that rely on it. > Therefore I propose until further discussion > to just keep it as it is and just fix the pointer arithmetic bug. > > Add missing void* cast to rx descriptor pointer in order to > properly skip the initial 4 bytes of the rx descriptor > when passing it to trace_ath10k_htt_rx_desc trace function. > > This fixes the pointer arithmetic error detected > by Dan Carpenter's static analysis tool. > > Fixes: 6bae9de622d3 ("ath10k: abstract htt_rx_desc structure") > > Tested-on: QCA6174 hw3.2 PCI WLAN.RM.4.4.1-00157-QCARMSWPZ-1 > > Signed-off-by: Francesco Magliocca > Link: https://lore.kernel.org/ath10k/20220201130900.GD22458@kili/ > --- > drivers/net/wireless/ath/ath10k/htt_rx.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c > index 9ad64ca84beb..e01efcd2ce06 100644 > --- a/drivers/net/wireless/ath/ath10k/htt_rx.c > +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c > @@ -429,7 +429,7 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt, > RX_MSDU_END_INFO0_LAST_MSDU; > > /* FIXME: why are we skipping the first part of the rx_desc? */ > - trace_ath10k_htt_rx_desc(ar, rx_desc + sizeof(u32), > + trace_ath10k_htt_rx_desc(ar, (void*)rx_desc + sizeof(u32), since void pointer arithmetic is undefined in C99 would it be "better" to cast as u8 *? I realize that gcc has an extension to support this [1], but this usage will cause a warning when -Wpointer-arith is used. [1] https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html