Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp520732ybx; Tue, 5 Nov 2019 01:08:24 -0800 (PST) X-Google-Smtp-Source: APXvYqw7SYjaXh2nC24B1gWgihXzalKMVB+/Q0h1LRTybMR0GlzT7Gl52HhQuzHtirRIxmA0Y8nD X-Received: by 2002:a17:906:e291:: with SMTP id gg17mr12011291ejb.209.1572944904528; Tue, 05 Nov 2019 01:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572944904; cv=none; d=google.com; s=arc-20160816; b=K8Xt2wixiuKzXBh/sBmn4u7pdfFiGZYZqgv6WWR40TCIHvNSkbgbkx7rpKUH7udQZR O7YDVp9LB80XomWDrk4S1itnUdIlcMzxioJcQpK8cs+XLFE2fC7beIRoFo3lhFGLYQ06 YnKigYm6a2+226SZjh7ft/TUJ84Z9qMeEyq2D8nLKO8Q/ShWW3rKn97YsXbgrnpzF8YQ Vtr46w1/Wjc9cFnM1cNZv0VAC29TWNRkIFF2vtk5xJ1tGCZzst4kd0Rgsk5zD0YaaB8T KAhliMSePWuaWw4tC6xfltQum1IPp4LWoVNkcop971AKv1EVYrtBdiaoTT3RFmhky+qa LgHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:authenticated-by; bh=rHyF9XY+RcqIfYYgga3dPntj1CJDcaaUVKwhU4adJ2M=; b=CQ8brjB0JVXsYR5hGwpNu15hR50iCS/WCClBlCe1KBLT+Mk+Gi7TYWSCKKcjc0L28z OmIvBJMP4fh3f/NmGDtTpWssgncIw11jxwjLrpx1+qD5DpsU0Q3eA5VqD5TXNXSd+afJ g29qTs1KynkaT7UKA+htOwZkMQYjwNFxnoVhmo5qryfMZ4f6BC1f3srnhFs9KXSLQplr ovX8KXGNe6jSLkQJ4CP+eWrRjKxuIxFEgsLQJKdZ5jASulloizDGkxyqjWQ0trCAT6IB uExiyDiMQpkrNIVlDBanmtFY4D6FLuia3tTwWvixQTG4t8vez4YtwM2A5sKADFT/SsZ6 0y2g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dv5si4630715ejb.242.2019.11.05.01.07.58; Tue, 05 Nov 2019 01:08:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730569AbfKEJGI (ORCPT + 99 others); Tue, 5 Nov 2019 04:06:08 -0500 Received: from rtits2.realtek.com ([211.75.126.72]:39359 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727095AbfKEJGI (ORCPT ); Tue, 5 Nov 2019 04:06:08 -0500 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.62 with qID xA594jvo004848, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (RTITCASV01.realtek.com.tw[172.21.6.18]) by rtits2.realtek.com.tw (8.15.2/2.57/5.78) with ESMTPS id xA594jvo004848 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 5 Nov 2019 17:04:45 +0800 Received: from localhost.localdomain (172.21.68.126) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.468.0; Tue, 5 Nov 2019 17:04:45 +0800 From: To: CC: , Subject: [PATCH] rtw88: fix potential NULL pointer access for firmware Date: Tue, 5 Nov 2019 17:04:42 +0800 Message-ID: <20191105090442.8378-1-yhchuang@realtek.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.68.126] Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Yan-Hsuan Chuang Driver could access a NULL firmware pointer if we don't return here. Fixes: 5195b90426409 ("rtw88: avoid FW info flood") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Yan-Hsuan Chuang --- drivers/net/wireless/realtek/rtw88/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtw88/main.c b/drivers/net/wireless/realtek/rtw88/main.c index 021668f1b74f..de82d08ea29e 100644 --- a/drivers/net/wireless/realtek/rtw88/main.c +++ b/drivers/net/wireless/realtek/rtw88/main.c @@ -1024,8 +1024,10 @@ static void rtw_load_firmware_cb(const struct firmware *firmware, void *context) struct rtw_fw_state *fw = &rtwdev->fw; const struct rtw_fw_hdr *fw_hdr; - if (!firmware) + if (!firmware || !firmware->data) { rtw_err(rtwdev, "failed to request firmware\n"); + return; + } fw_hdr = (const struct rtw_fw_hdr *)firmware->data; fw->h2c_version = le16_to_cpu(fw_hdr->h2c_fmt_ver); -- 2.17.1