Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp867875rdb; Thu, 15 Feb 2024 19:40:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUAVDCsMUYGQGcrcFFbhaYEBTiEL2Z3My+AHwW0YwlCW8EUTTXv9N/eviRG15n9pi/s1y2JiCd5RwHe47SF7QnKF4DiS/qe9fM++mxjXg== X-Google-Smtp-Source: AGHT+IFoR+NJWOC4CLIGBz3aQpORzhau6d3dbuHIJ0KgxiGD4FkKUW9qUBiUc+upYNQKEUJsk3Ke X-Received: by 2002:a19:e006:0:b0:511:53fa:b971 with SMTP id x6-20020a19e006000000b0051153fab971mr2583440lfg.9.1708054823017; Thu, 15 Feb 2024 19:40:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708054822; cv=pass; d=google.com; s=arc-20160816; b=VEC4H773+hCijdISbVu7MJV0Zm1GMxLepAKtGTlHHG4X93wqD3zbg81JsOr59V43VR ldkIXI1uPVaJiCeur/PalS8rB52x94yjFP7mVGLpOPGVi0euqrn64oIJLFWsE4l8WFSJ LzG0YfnLfVBjJkltU1yEW2miOFAHU2Vys4UZl50VYKUN9VKiAcktaIuz3sykRDcDrSBS yxxuoRuypznYe0fUrPG/lff3qSaFNpHeG98RH7xLaM2mEvPbdbnxGZdwUGdVJl1Tirjb EAMzPbOjBybQYmi3+vKZaRsp8xGyeszoACb49jU5ybMtMZLkLH4Ge5xKjySdx+0B3e5y FzzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=m8zmiAG2OMk47kad8ILXtvtIiZt1gZ2V5GFrdf8H/0c=; fh=QpcZVC5DBuznXXfkj20ZVuSbJlzTDhd9/gr8cup05C8=; b=yayKUBOF7QbkxjSa7GRZbKd7OzFJGdQckua7OBTwVfFkl9tlH5zhpOA3wUzRSnQpZW RbTfbSlDFbLKu0ge8+1JOflCwhZdqr2RDgxaSU8x/+HVD69rnOyMOA6WeSVSaw8+2BJk eXM9dlVUQWSgE6aeYqgWJrDF7jc8hBlh1TZQLkF10R3ezrp+YQG3sWMxm5zkJdo/WxbI IqS1MwZhrCMQWXkoK2DpO4S8p/mjx4s3XjBVqKmKX7SnUhYixhh3TcCu9PsOSJLqoXXo +XtXAoWM3LmNMcsfPzT9Bs84vTqorexnOV/v9G3qXMIofDN5PGsc7SZjWVYpYwqfpO16 qpnw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-3657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3657-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gr18-20020a170906e2d200b00a3d00af17besi1178379ejb.781.2024.02.15.19.40.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 19:40:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-3657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=realtek.com); spf=pass (google.com: domain of linux-wireless+bounces-3657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3657-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B41E21F23279 for ; Fri, 16 Feb 2024 03:40:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 005D5FBEB; Fri, 16 Feb 2024 03:40:20 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1079DFBE9 for ; Fri, 16 Feb 2024 03:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708054819; cv=none; b=hKKyPDVlKfltASqBr5ebCWRAN+pjAmQE3gFxU1aesPjZHAAeoXhZlNFQFtVs4P5RR6WirS8kSF+2WBtITMmmGvcaeIKQfmvXvFwtb10vkMyMPuZOrrkc6sbOd6biRJDiuJKJINt/HXTaVjGhBQDYeo6ZaXEJ+TTPYA0ijVlHxag= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708054819; c=relaxed/simple; bh=TmGy1oZBUtjFf5JvZnS5vqKGzsirWauaIJxkBiR9zfg=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=BkDOmApiltQeKDLQLn5C85Yk1g8awO2yBEWYlVaN5KjPAjePmP7XHpQYuXsW73+RERbaAGoXBqNVv1EG9a92MmLv48NhXIF/ygq6oPptNlwUwiWyDjGP/rdvLBkc1ZnMSx73pldAHE3iIH2cx4jOjMr5oByZJfPEBj6YBumdHy8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com X-SpamFilter-By: ArmorX SpamTrap 5.78 with qID 41G3e1As92751774, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36506.realtek.com.tw[172.21.6.27]) by rtits2.realtek.com.tw (8.15.2/2.95/5.92) with ESMTPS id 41G3e1As92751774 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 16 Feb 2024 11:40:01 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36506.realtek.com.tw (172.21.6.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.17; Fri, 16 Feb 2024 11:40:00 +0800 Received: from [127.0.1.1] (172.21.69.94) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 16 Feb 2024 11:40:00 +0800 From: Ping-Ke Shih To: , CC: Subject: [PATCH] wifi: rtl8xxxu: check vif before using in rtl8xxxu_tx() Date: Fri, 16 Feb 2024 11:39:23 +0800 Message-ID: <20240216033923.34683-1-pkshih@realtek.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: RTEXMBS02.realtek.com.tw (172.21.6.95) To RTEXMBS04.realtek.com.tw (172.21.6.97) The 'vif' is from tx_info of SKB, and other codes check 'vif' before using, which raises smatch warnings: drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c:5656 rtl8xxxu_tx() warn: variable dereferenced before check 'vif' (see line 5553) Compile tested only. Signed-off-by: Ping-Ke Shih --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 66bf92c164c3..40edf55d8e4a 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -5550,7 +5550,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw, struct rtl8xxxu_tx_urb *tx_urb; struct ieee80211_sta *sta = NULL; struct ieee80211_vif *vif = tx_info->control.vif; - struct rtl8xxxu_vif *rtlvif = (struct rtl8xxxu_vif *)vif->drv_priv; + struct rtl8xxxu_vif *rtlvif = vif ? (struct rtl8xxxu_vif *)vif->drv_priv : NULL; struct device *dev = &priv->udev->dev; u32 queue, rts_rate; u16 pktlen = skb->len; @@ -5621,7 +5621,7 @@ static void rtl8xxxu_tx(struct ieee80211_hw *hw, default: break; } - if (bmc && rtlvif->hw_key_idx != 0xff) { + if (bmc && rtlvif && rtlvif->hw_key_idx != 0xff) { tx_desc->txdw1 |= cpu_to_le32(TXDESC_EN_DESC_ID); macid = rtlvif->hw_key_idx; } -- 2.25.1