Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp181391pxx; Wed, 28 Oct 2020 01:54:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWXgiToilXN6a4jcsj+LGUVjehHjRbhKZ/ThL94bCU6quKzvr9ijU2/qnNe5zmct1znVMH X-Received: by 2002:a17:906:b03:: with SMTP id u3mr583511ejg.3.1603875251602; Wed, 28 Oct 2020 01:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603875251; cv=none; d=google.com; s=arc-20160816; b=dbfxCeMQe8UXZQQOpu57IwVEpgQHIE1seAOCaJRTIGeJyc4wfURQ4hdqd7DvdB0egd iuF/B5CYBOC3Oi5gRqvmVwXXYHqyjs0LsK1nC5JFBI3Bso2mE33zaq1ghqwLkA8AQ1Np XBOVI8quc4WhOMtOFuwaF3wI8welcXV1kAuginJOI1tQjL/5+hQFSyTopbpBhh2PYr37 Tnn9RjSPP/xSYllyr2QUZAal5CvuetgQ36dXuC3LoVaYP5v7QlA+qv01uXykUlY5Hvqp ERmC28LeT557jouFCBfP3nW/GihgPy6JKGmmZJJ5G933rLDMjFrdiSfvV63DlyWY6MD/ eKog== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oKkTuYx0ifC/LjJmN4C6t7/dB7tPhxmz1DourETwsus=; b=K7wBGSw4kttQ/MlMSGxKQGDVVGYOOUieo94VufSyRXcjvDDPpPxYAYt0vHDu0T3jsz L3kUpbKUcKb38CgaS3ed3Gaz+FkgpvGbLdHNo/ZnZQHZA6tj21MoR/k5St3nZFXQ7H4e otS31ujUEKEiZH4jDk7Jot0naGaiIMBXH0+RaWmx+TRtF0RUQd5WRCN9zINK3ILySLzY zQO3uKxhxgebBNF/uH6YCRwhoqmcwup9AB+JHqZnYtMQBPMymPq/OkoIJB+Dcffwlsu2 zYlcOb8YwH4fLNshls4XzoZ+rLa1FTWe7bfd0WxX0+Ve3rPtwTat40K9ElHqdGphikBE dLMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fVLOyPAX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f19si2736409edx.542.2020.10.28.01.53.49; Wed, 28 Oct 2020 01:54:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=default header.b=fVLOyPAX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756467AbgJ0ON1 (ORCPT + 99 others); Tue, 27 Oct 2020 10:13:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:59166 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755485AbgJ0OKG (ORCPT ); Tue, 27 Oct 2020 10:10:06 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E41302072D; Tue, 27 Oct 2020 14:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807805; bh=3FSq1EhZdfDup8CjiAUD2ypmmOkblGi6RFdoaTOmGyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVLOyPAX1QD4DQB3rmcbPB1kFa+hlaoZp+bJpJgIL3pFUmFFyhFP3ETQqRBiW/M2y aIY1ERWLCmRK0ACytq7yJSM1pfq1GmPNK25E9emAbo6pPpzThKIR5nUvjsMOsmeUy+ AMM4+6unMx3TdIV4J5FmIuWZB/Jlw8dnhqcOqy3w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Rix , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 048/191] brcmfmac: check ndev pointer Date: Tue, 27 Oct 2020 14:48:23 +0100 Message-Id: <20201027134912.046558842@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix [ Upstream commit 9c9f015bc9f8839831c7ba0a6d731a3853c464e2 ] Clang static analysis reports this error brcmfmac/core.c:490:4: warning: Dereference of null pointer (*ifp)->ndev->stats.rx_errors++; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In this block of code if (ret || !(*ifp) || !(*ifp)->ndev) { if (ret != -ENODATA && *ifp) (*ifp)->ndev->stats.rx_errors++; brcmu_pkt_buf_free_skb(skb); return -ENODATA; } (*ifp)->ndev being NULL is caught as an error But then it is used to report the error. So add a check before using it. Fixes: 91b632803ee4 ("brcmfmac: Use net_device_stats from struct net_device") Signed-off-by: Tom Rix Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200802161804.6126-1-trix@redhat.com Signed-off-by: Sasha Levin --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c index bfc0e37b7f344..590bef2defb94 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -318,7 +318,7 @@ static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb, ret = brcmf_proto_hdrpull(drvr, true, skb, ifp); if (ret || !(*ifp) || !(*ifp)->ndev) { - if (ret != -ENODATA && *ifp) + if (ret != -ENODATA && *ifp && (*ifp)->ndev) (*ifp)->ndev->stats.rx_errors++; brcmu_pkt_buf_free_skb(skb); return -ENODATA; -- 2.25.1