Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5122413rwr; Mon, 8 May 2023 18:51:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6UKY3lB2o1FFfjNJraIIqRfHg+2vd/GMT/6cO3QBLVECQLTaI6iUi8k07BTvqeJSxMd7oE X-Received: by 2002:a05:6a21:158f:b0:f6:3a10:eac1 with SMTP id nr15-20020a056a21158f00b000f63a10eac1mr11575363pzb.62.1683597059878; Mon, 08 May 2023 18:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683597059; cv=none; d=google.com; s=arc-20160816; b=q/azhicZEompcbnwisSs7Ju8akd+++wEulY3GE8tKCeGiG1S8PrkHCKAiefUjWqXXL YtoP1JBBhyDoRZyfYgV3Ar4D4dY1FHOTg2+CwXm5bRTbK+JkqOBP7+Sx7AVdxVtIsIwh 7Cz8LHXw3gwFFOKZWPmnCzg7MT2Vq15PWMI4OHGTMQJfPiztV8qnLklpeLLmv2OeF+V9 xm31NDXL0pywrDm1Nx0H5JWWWGtU5tLiOEL+txY1h9B1zEnOws3PVq+89bBhVG8oY79R x2TBjEjzDQ3+4uZxFzPZvAAk//liNKfQM9rM63J9T6sIgpnpqXQEPaE49gflfbbV2ZTD KrAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=zeqDFAMBKmoT/g81hl2hQIeucwKvcq8VOvv07+thxgU=; b=fZsOT1mgGPrmDMPileViHqJKijWaNoZVBu9KPMEAGYtNILQhirtA0Uk0xz4By4KNjK bgn/Uw0z1v6b9WA0dzFbjdUQuanOcAml3i8nFruE/BeFJv1npcQQBJBUy/D6vayCv1rk uVzU2/5F0yCbN9QEpnIjfOQyDIGs7ECtB/9IpmcphF+A7SRAnYtoTO2zVQQwEDfWOlIc epT1yNW5YF82zEQ2wDeWUYqrE1Lri0IJyywSqOW+RS1goNevLMf2mWIBFXtAKaDWLv4w GNuuKZBQoD6wUQ91d3/eNnFsB4vlohG16SO+hAP3pts/k76r0zSRX8t+LBMkOwjwD/Md HOxw== 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 q17-20020a63bc11000000b00519d69a233csi314093pge.626.2023.05.08.18.50.44; Mon, 08 May 2023 18:50:59 -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 S232747AbjEIBgF (ORCPT + 99 others); Mon, 8 May 2023 21:36:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230113AbjEIBgC (ORCPT ); Mon, 8 May 2023 21:36:02 -0400 X-Greylist: delayed 832 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 08 May 2023 18:36:00 PDT Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30B2D49D9; Mon, 8 May 2023 18:35:59 -0700 (PDT) Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pwC3G-00022c-03; Tue, 09 May 2023 01:22:02 +0000 Date: Tue, 9 May 2023 03:20:06 +0200 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno Subject: [PATCH net] net: ethernet: mtk_eth_soc: fix NULL pointer dereference Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 Check for NULL pointer to avoid kernel crashing in case of missing WO firmware in case only a single WEDv2 device has been initialized, e.g. on MT7981 which can connect just one wireless frontend. Fixes: 86ce0d09e424 ("net: ethernet: mtk_eth_soc: use WO firmware for MT7981") Signed-off-by: Daniel Golle --- drivers/net/ethernet/mediatek/mtk_wed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c index 4c205afbd230..985cff910f30 100644 --- a/drivers/net/ethernet/mediatek/mtk_wed.c +++ b/drivers/net/ethernet/mediatek/mtk_wed.c @@ -654,7 +654,7 @@ __mtk_wed_detach(struct mtk_wed_device *dev) BIT(hw->index), BIT(hw->index)); } - if (!hw_list[!hw->index]->wed_dev && + if ((!hw_list[!hw->index] || !hw_list[!hw->index]->wed_dev) && hw->eth->dma_dev != hw->eth->dev) mtk_eth_set_dma_device(hw->eth, hw->eth->dev); -- 2.40.0