From patchwork Tue May 9 01:20:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 91329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2557878vqo; Mon, 8 May 2023 18:51:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ76ftEAXDED02LQKy4MVcxciXovvPrB4ckCE7VxwotYhngR7/LZNtvMIgqAQM190MmfX2gf X-Received: by 2002:a17:902:c102:b0:1ac:4735:45d7 with SMTP id 2-20020a170902c10200b001ac473545d7mr12036885pli.6.1683597069887; Mon, 08 May 2023 18:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683597069; cv=none; d=google.com; s=arc-20160816; b=Vh4oUXyshg00TmIhW4IoPf0rvRrQfxKMqHEDWOj/KASTxxTgGBhvUridrGFGiURWM2 o187bzV5Xtz5CF3Uwqk0RuOa9vuPyCYzUgUxFv2SK7V67iPMokTbkhBodrTCtmftdk5T NsR2fSkK8YTO9sc090uHGNyz3s0POsiya6rSYnHe3FHOo9gLXhi7sfVZWeKyIhmev5KM ZuaCRDwXqnEBCG8FS46HA35mbW1H7RC28H/2po/ELgK5KFEO0q2YwNHk3EQJy9AQrmV6 lTguxxzDa75Jz7rZWjJHETVX6/u5swF7gKoG23WQRFo7eQb4Nh3b8u5vyCNvgVHdQB0E SW2g== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a170903230400b001ab1d1a6802si390320plh.1.2023.05.08.18.50.55; Mon, 08 May 2023 18:51:09 -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 S229726AbjEIBgF (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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765379481417836793?= X-GMAIL-MSGID: =?utf-8?q?1765379481417836793?= 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 Reviewed-by: Simon Horman --- 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);