From patchwork Tue Apr 18 14:29:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 84909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2915614vqo; Tue, 18 Apr 2023 08:00:05 -0700 (PDT) X-Google-Smtp-Source: AKy350YI3+fWJwx9sUEwbB8+5wp96EfBUHWedEd6NcBnzMS/BUXN+IPEZFgO/UWvdsc6l4Nbjup4 X-Received: by 2002:a05:6a00:1a89:b0:63b:62d1:d868 with SMTP id e9-20020a056a001a8900b0063b62d1d868mr103210pfv.8.1681830005006; Tue, 18 Apr 2023 08:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681830004; cv=none; d=google.com; s=arc-20160816; b=CPmfKrHl0zwrI15vH4g4nGMQITSSZvhQXCOBc5BQcQ8yYE8QnjJlj7ADqvvy9lxXnz vBkqy2VUhu6wtOCdpq2h8MEKeEl+72HEsdvTKk/RSRQjNnY6HvwlbCelQn1py95a2GIL BkXfEFYmfia82dZa9R/mX8on9qo6zYfiBiJFCEasnNaoYbBaNDtg80UVyoiDNBOLhPSY bM7OfSx7aZdnDuwaU/4OZIGA6dB7NEoRl6ul906Geo2yx2Dch/OH164r4CkmVeWkjz8N n5QHjdtrL2S6qu6YSSTVvMFlDvL92xwGHb8RQDi7BDEJtraBliUrUrV/2AKY2uh2/4xX aL+w== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l189-20020a6225c6000000b00628a75401bdsi8960411pfl.142.2023.04.18.07.59.50; Tue, 18 Apr 2023 08:00:04 -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 S231635AbjDRO33 (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763526579064532388?= X-GMAIL-MSGID: =?utf-8?q?1763526579064532388?= 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 Reviewed-by: Larry Finger --- 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)