Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp529091pxx; Wed, 28 Oct 2020 10:22:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkIXnvH37SMtwCi46cA3vsxIui1kNCREyW1+/hHcxSigQMqb+Hap0cyqhIXH5gp6Yvl2ES X-Received: by 2002:a17:906:bc91:: with SMTP id lv17mr85308ejb.249.1603905725131; Wed, 28 Oct 2020 10:22:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603905725; cv=none; d=google.com; s=arc-20160816; b=iecvvqJlsr36LH9UJb3YXpREOsUZwKBViUS6q64l67qFdPulT46nbhqEVT2yIyoNmS F1d+w75uyxm7YkZtqKFdEGi3lcDm10rzxEP7Ev0ps10PRYBxremPc8B3sUb/nJz/d/86 mwENtHaaM/6Es95co0UxwJGLcYXnrUb0NBLTcLcOL42zEyX5R6KsQ+stZ0xU9Nh1OQun 7FOb1eVVrGoeVM7zeyHZKua916G9dlh4Cj1w9sUXK0MSYIKrmwpxeWjJK83DZKhcBY6t BFN5gyQwB1B/KhYqke6UHBAn8N1UclONbMr4FYrcRcfFQyEdtn2FZIxM1QyqoQ9Aq1DT ZlSg== 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=t8mC05fwjSgxL8+fVkISJxYjSGXj0SmEOpeEJ5eGWvE=; b=fNxIQZ4cjtmpJyHqvVJwReEECqJt38hxEEyrekR7DsFgKoBkBntV6i/x566cHWOda3 Ah6dxbVCDlQfjLjRKlzoxlMHwdGYaXvnTa5Bl7PSWG12gg9TQfr+npzWH8oq9P0L1AKI 3dFoHd00ZRkE4OQQ8IUvrAFOORz+FP6088OWiwLpPzrSZQ11zYD+ANy5eERFVtu2ypOw d+mreWfN4smp8AJvVax/anuCyeDfnMlQxedADUDNFkmdjfQfKvTJZGym96T8OURmJRWJ skPIdwAQyFBH2GVw0AuIMiT66vaz3jxSfOr0aZC7p/s5lyKP6IrMWyobmoh4xfrHBQX9 jMmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DE8joX29; 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 i9si3854304eje.410.2020.10.28.10.21.41; Wed, 28 Oct 2020 10:22:05 -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=DE8joX29; 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 S1821115AbgJ0Rkk (ORCPT + 99 others); Tue, 27 Oct 2020 13:40:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:60784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2902468AbgJ0Ods (ORCPT ); Tue, 27 Oct 2020 10:33:48 -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 8EBBB20773; Tue, 27 Oct 2020 14:33:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809228; bh=ykvyhW/ve4gwugZ7NKpp1QA6N4hz+Ae24fTqa7dAQJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DE8joX2970YWHLKowSyaeo5paQzdR+EfF4mK5PvpkuNwoFF7WSZg+hyN6js5BFazl s9/FkCsC/4r+VWyTcZjA35m78WEv7j6SSRUaeeVa0HltEaZ36DvZra5JZhMDALfKTC N+8LxRUwJbZymofEDJXgJsJZd8M+6TTAb9ssNNYQ= 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 5.4 114/408] brcmfmac: check ndev pointer Date: Tue, 27 Oct 2020 14:50:52 +0100 Message-Id: <20201027135500.392022349@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 85cf96461ddeb..e9bb8dbdc9aa8 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -483,7 +483,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