Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5508815rwe; Tue, 18 Apr 2023 07:48:10 -0700 (PDT) X-Google-Smtp-Source: AKy350bbCDyCwPVHuRzZEKwXjqoKuJIAh7dj8mUWRuN+mE0WMMG9MR8tNimx5TPO4y36EPwNMhfO X-Received: by 2002:a17:903:2094:b0:1a1:d624:2fe2 with SMTP id d20-20020a170903209400b001a1d6242fe2mr1916667plc.17.1681829290490; Tue, 18 Apr 2023 07:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681829290; cv=none; d=google.com; s=arc-20160816; b=ArKTkHkJT+00qH5I16vj4Hakk4BXW6qIDsmX8TfMjqAqtz+kgI5wMDU+liA0g58Dhn TI3ogtVFUvK35rWHKnXHyqIw/q5G0v+ogwDCizgsfW80MTYbq+PSoQWH2Drz4IdOTNbZ qcE/hoi5lFjZX9yaKrkc3O8na6gvmSxpkifAm98Ub1JaeWDos84uvMo9uC2HSFqdy2ND 1XDzQHDN83V7PHqicTGNxJTtsuit96QYOFfph4U6cptXuCVO/HkeinLuQto8YjgWsZ4L fKNjAqkJfNx+9+Zvjn+IKLzTIHK7wVaS+NDuaOQ0UXTszyaTrkFAtxKwjDtUnMPbM50f rmkg== 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 :message-id:date:subject:cc:to:from; bh=OrXowOnFfJaG6QJqFEdFpUCcxC5PyKbITJu/owFfKdI=; b=fgGySdK/149uipml/z1DIlduFXciDw4H+Mkg5RbW0f5r+I0dY60w6VbQHH5h9lZYka 19E7UlQdTBLsIwGtCYH9OAbdmKbyU0UNZo92zFZXCTGmyDsP2kL3bVMpttF3r8O/ZZFe TaWwGghsK8VVgcMc+TAyFC5T2TdS3ADSRYR2BLgnfqQn9A13r4mzjyz3camhGZV095BS J5jSxWcJkrx/Xh2UHoi7Fnzw5vS0sYDcjHBeRuHtcUGgVoTzc0TyLZ/XSbsXr6YNPl7h hpIog3R71tHXmcRL5iG0b7LHgkXArwVs7oaA7lKEULhBi+JuuieVZkFSKg+9/1PlqVbT i5eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l18-20020a170903245200b001a6492cdf2bsi15067233pls.343.2023.04.18.07.47.39; Tue, 18 Apr 2023 07:48:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231593AbjDRO33 (ORCPT + 99 others); Tue, 18 Apr 2023 10:29:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231499AbjDRO30 (ORCPT ); Tue, 18 Apr 2023 10:29:26 -0400 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8946DD; Tue, 18 Apr 2023 07:29:24 -0700 (PDT) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 18 Apr 2023 17:29:23 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 18 Apr 2023 17:29:22 +0300 From: Nikita Zhandarovich To: Larry Finger CC: Nikita Zhandarovich , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "John W. Linville" , , , , , , Natalia Petrova Subject: [PATCH v2] b43legacy: Add checking for null for ssb_get_devtypedata(dev) Date: Tue, 18 Apr 2023 07:29:18 -0700 Message-ID: <20230418142918.70510-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since second call of ssb_get_devtypedata() may fail as well as the first one, the NULL return value in 'wl' will be later dereferenced in calls to b43legacy_one_core_attach() and schedule_work(). Instead of merely warning about this failure with B43legacy_WARN_ON(), properly return with error to avoid any further NULL pointer dereferences. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 75388acd0cd8 ("[B43LEGACY]: add mac80211-based driver for legacy BCM43xx devices") Co-developed-by: Natalia Petrova Signed-off-by: Nikita Zhandarovich --- v2: fix issues with overlooked null-ptr-dereferences pointed out by Simon Horman Link: https://lore.kernel.org/all/Y+eb9mZntfe6rO3v@corigine.com/ drivers/net/wireless/broadcom/b43legacy/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/broadcom/b43legacy/main.c b/drivers/net/wireless/broadcom/b43legacy/main.c index 760136638a95..5a706dd0b1a4 100644 --- a/drivers/net/wireless/broadcom/b43legacy/main.c +++ b/drivers/net/wireless/broadcom/b43legacy/main.c @@ -3857,7 +3857,11 @@ static int b43legacy_probe(struct ssb_device *dev, if (err) goto out; wl = ssb_get_devtypedata(dev); - B43legacy_WARN_ON(!wl); + if (!wl) { + B43legacy_WARN_ON(!wl); + err = -ENODEV; + goto out; + } } err = b43legacy_one_core_attach(dev, wl); if (err) -- 2.25.1