From patchwork Mon Sep 27 12:16:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 514680 Delivered-To: patch@linaro.org Received: by 2002:a17:906:f46:0:0:0:0 with SMTP id h6csp3880084ejj; Mon, 27 Sep 2021 05:17:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+glTJBlfdJILA1bbsTzfc7kpeshxtConCsOePMOZyZHebtAEoKHWJM77lQzkkvsjWLffF X-Received: by 2002:a17:90b:e0e:: with SMTP id ge14mr3172745pjb.138.1632745029605; Mon, 27 Sep 2021 05:17:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632745029; cv=none; d=google.com; s=arc-20160816; b=hq+JJHnjJTKYJ0RhkuU+yaNzipJ9ELVQKOZkJ8TQnmf4esL7BuIiMr/YpEb3NKkvhp m5zXxO1V2ritbhewb5CeA+SelnkUNZRoczOZslYsA0EpjAYJQkG41w3JyKhe2ZXYjWNR J9IYOYfKpPEtC7mDDyiKkp0A+LD9dvHkqdSvOTXsaaA4wd2ZfVJPJ0itsRttQrCcwkIY b4/UAii//gm7wtdrIboJsnVpaAGwwKheATZi9il+oCkP7g0tYegPn9o8OpXRs7IqhGnQ S8wAJKo6a/5+dZ5tbSJE7Z+y5ueKUFqz6nfOh+B07E2YpruZu/61ck+pck3Rupm9p4cT BPvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=+gXplOKAhobis/BOKAFujwjKYkPT4kVBbDpaAcRddxo=; b=cfqkbpsjAIBuhfgACq3fXZUrS8l+b8hCjLcrEKv5v8H961P7PUnAKUrzAHMPZTYNOz YXWrmzVpPGGBNWQx0E8GXgsyy9UlK6hEJlGv/F9OKPh1neWuh3KETpv1DdD4sxlKHig0 DWA54Jn0bQw9cGksygzCDRBSJvhhByRUMhOe7lStVJ4wRGS+cJ5rtInFLe9DK1EeuV/G 983NUciPcanW8jD583AAeNsFCGUNv/TpHGW8nuptdbNbXWPFtXOva9onsombgO5ujLyJ Vsll7T+Orf7r2SPbvdcO0CnlhwWtzYTTJZlGSDEyAzqcQFhZf0zpXck7aIWXoeniwqVO 46CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAoQb5O0; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m22si12797611pgd.318.2021.09.27.05.17.09; Mon, 27 Sep 2021 05:17:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YAoQb5O0; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234305AbhI0MSm (ORCPT + 3 others); Mon, 27 Sep 2021 08:18:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:42284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234213AbhI0MSj (ORCPT ); Mon, 27 Sep 2021 08:18:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4744A6103B; Mon, 27 Sep 2021 12:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632745021; bh=kg6cqnxzry6/+Av1WRHhc3o3FRqLV9iNvalhK8jK0I0=; h=From:To:Cc:Subject:Date:From; b=YAoQb5O0Qg44lcoRdQPW2cCt4aC4f4bBHW7tXweJWw/zQXN8VzDdk079kZk+uFOdH XAgnN1r8aDLZvWeALDKcYNOHCM69BmN6/CjNtZMY4k+KG7AgIMxA/SsmL0RZQtrnkh lroyVZssRyyVKZ80TfThBbfSBzKCIyR3FVSxtiM83wh67dL0OeJFJve2olbZjIrh8Q r3MYmj1pFFbRtL54JNwKXov5YaBJVG14uvBr7Ax0y5q/LyGP9x30WBkcAlDJ9umDT6 cp69bOHg3eiZwJCMHI+Uum4JKDJ49sky3CpQKCDt8q/NJRl98wavT20M1sGtcVviwO OH69STxaYIrZg== From: Arnd Bergmann To: Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu , Kalle Valo Cc: Arnd Bergmann , "David S. Miller" , Jakub Kicinski , Nathan Chancellor , Nick Desaulniers , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] mwifiex: avoid null-pointer-subtraction warning Date: Mon, 27 Sep 2021 14:16:35 +0200 Message-Id: <20210927121656.940304-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Arnd Bergmann clang complains about some NULL pointer arithmetic in this driver: drivers/net/wireless/marvell/mwifiex/sta_tx.c:65:59: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction] pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)- ^ drivers/net/wireless/marvell/mwifiex/uap_txrx.c:478:53: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction] pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) & Rework that expression to do the same thing using a uintptr_t. Signed-off-by: Arnd Bergmann --- drivers/net/wireless/marvell/mwifiex/sta_tx.c | 4 ++-- drivers/net/wireless/marvell/mwifiex/uap_txrx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.29.2 diff --git a/drivers/net/wireless/marvell/mwifiex/sta_tx.c b/drivers/net/wireless/marvell/mwifiex/sta_tx.c index 241305377e20..a9b5eb992220 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_tx.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_tx.c @@ -62,8 +62,8 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv, pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0; - pad = ((void *)skb->data - (sizeof(*local_tx_pd) + hroom)- - NULL) & (MWIFIEX_DMA_ALIGN_SZ - 1); + pad = ((uintptr_t)skb->data - (sizeof(*local_tx_pd) + hroom)) & + (MWIFIEX_DMA_ALIGN_SZ - 1); skb_push(skb, sizeof(*local_tx_pd) + pad); local_tx_pd = (struct txpd *) skb->data; diff --git a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c index 9bbdb8dfce62..245ff644f81e 100644 --- a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c +++ b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c @@ -475,8 +475,8 @@ void *mwifiex_process_uap_txpd(struct mwifiex_private *priv, pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0; - pad = ((void *)skb->data - (sizeof(*txpd) + hroom) - NULL) & - (MWIFIEX_DMA_ALIGN_SZ - 1); + pad = ((uintptr_t)skb->data - (sizeof(*txpd) + hroom)) & + (MWIFIEX_DMA_ALIGN_SZ - 1); skb_push(skb, sizeof(*txpd) + pad);