From patchwork Tue Aug 13 07:07:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 11091317 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A0A61399 for ; Tue, 13 Aug 2019 07:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4569628585 for ; Tue, 13 Aug 2019 07:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38ED3285C3; Tue, 13 Aug 2019 07:07:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A7AF28585 for ; Tue, 13 Aug 2019 07:07:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726287AbfHMHHU (ORCPT ); Tue, 13 Aug 2019 03:07:20 -0400 Received: from nbd.name ([46.4.11.11]:60658 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725820AbfHMHHU (ORCPT ); Tue, 13 Aug 2019 03:07:20 -0400 Received: from pd95fd499.dip0.t-ipconnect.de ([217.95.212.153] helo=bertha.fritz.box) by ds12 with esmtpa (Exim 4.89) (envelope-from ) id 1hxQtp-0002qG-Ew; Tue, 13 Aug 2019 09:07:17 +0200 From: John Crispin To: Johannes Berg Cc: linux-wireless@vger.kernel.org, John Crispin , Dan Carpenter Subject: [PATCH] mac80211: fix possible NULL pointerderef in obss pd code Date: Tue, 13 Aug 2019 09:07:12 +0200 Message-Id: <20190813070712.25509-1-john@phrozen.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP he_spr_ie_elem is dereferenced before the NULL check. fix this by moving the assignment after the check. fixes commit 697f6c507c74 ("mac80211: propagate HE operation info into bss_conf") This was reported by the static code checker. Reported-by: Dan Carpenter Signed-off-by: John Crispin --- net/mac80211/he.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/mac80211/he.c b/net/mac80211/he.c index a02abfc424aa..736da0035135 100644 --- a/net/mac80211/he.c +++ b/net/mac80211/he.c @@ -72,12 +72,13 @@ ieee80211_he_spr_ie_to_bss_conf(struct ieee80211_vif *vif, { struct ieee80211_he_obss_pd *he_obss_pd = &vif->bss_conf.he_obss_pd; - const u8 *data = he_spr_ie_elem->optional; + const u8 *data; memset(he_obss_pd, 0, sizeof(*he_obss_pd)); if (!he_spr_ie_elem) return; + data = he_spr_ie_elem->optional; if (he_spr_ie_elem->he_sr_control & IEEE80211_HE_SPR_NON_SRG_OFFSET_PRESENT)