Message ID | 20221115090433.232165-1-tanghui20@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2603624wru; Tue, 15 Nov 2022 01:11:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf6z+fVL9Zsrdhkl9JvPkkAidvRKpfTgclER0jf169NkdmXNz+KYuquXS8626xkgUeb9UDED X-Received: by 2002:a05:6402:378c:b0:463:ab06:f338 with SMTP id et12-20020a056402378c00b00463ab06f338mr14141077edb.371.1668503507757; Tue, 15 Nov 2022 01:11:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668503507; cv=none; d=google.com; s=arc-20160816; b=AIv+OjmprCPuBHt6gcn3B6Kz67zeV0M+szz7fZJTMzAY4/skEn1jj6v/uVhvOT+dhm 31l0sinLXiCUHaMLBUINAdXm4JKlvmqHucrQ626QBTYGwiGFgGxlDibnjm7VgVjvWtyC Im6z2GgI19fG5DvDFU7BXtBGdWR4gEsv29ICO98Jn7+6GRSLv9xk1fh1sXr0TYQdqZqf HJ95CutlbBcoTGMi6osYBRR8cWyTcJDUCl4W0MdFqx2jFuZe5kfI76USvqDjtRNiU92l 8W64BDNA0jNM73ftTrHd6GEa4kMiVBYbqPD/iemxUXrJeJdXcbl0bd19fg1qtWpPalNC FyrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=jy+YcAHGGRI7naN8Xlp4Mg8tyW78c4FvFGkovwWZ8gE=; b=LbMkWJ9VDw+Pchch+0trHal5arRtrcGG1Gc1xBp01zyWCjdzjQBcIQ7xLMdQL/xT21 I1mkQZ2fGIksCljHXctQ7qtctuO9hlvlU97G0L/gNMGSUuDyKnMRXx+swsOyyfYdyhVQ DBspiSKcCr56rI5P2ZPh9+k9NqhGAItSnfNqlk0EFjNoC0ar3TpGXUZ7Cjfzcac6SzK8 FSDUY8fhkCQesXO3iVDtodBjV/ZEYvE10BM5c8CrrOvB+0gujwpAzMWkgnj8ZtOHneTb JxHy0IupyaNMQU3WOfLZ9X3t3LiXDIKPe5Bo9p3Y9sBnUq0FGPEztdBeHNqw6z1w3diD RiuQ== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r14-20020a05640251ce00b0046775f92f19si9568231edd.50.2022.11.15.01.11.23; Tue, 15 Nov 2022 01:11:47 -0800 (PST) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237631AbiKOJI0 (ORCPT <rfc822;zwp10758@gmail.com> + 99 others); Tue, 15 Nov 2022 04:08:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237649AbiKOJIS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 15 Nov 2022 04:08:18 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A9A1E71F; Tue, 15 Nov 2022 01:08:15 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NBKy95RNpzJnj5; Tue, 15 Nov 2022 17:05:05 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 17:07:44 +0800 Received: from ubuntu1804.huawei.com (10.67.175.30) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 15 Nov 2022 17:07:44 +0800 From: Hui Tang <tanghui20@huawei.com> To: <davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>, <mw@semihalf.com>, <linux@armlinux.org.uk>, <leon@kernel.org> CC: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <yusongping@huawei.com> Subject: [PATCH net v2] net: mvpp2: fix possible invalid pointer dereference Date: Tue, 15 Nov 2022 17:04:33 +0800 Message-ID: <20221115090433.232165-1-tanghui20@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.30] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749536455467972152?= X-GMAIL-MSGID: =?utf-8?q?1749552734325858102?= |
Series |
[net,v2] net: mvpp2: fix possible invalid pointer dereference
|
|
Commit Message
Hui Tang
Nov. 15, 2022, 9:04 a.m. UTC
It will cause invalid pointer dereference to priv->cm3_base behind,
if PTR_ERR(priv->cm3_base) in mvpp2_get_sram().
Fixes: a59d354208a7 ("net: mvpp2: enable global flow control")
Signed-off-by: Hui Tang <tanghui20@huawei.com>
---
v1 -> v2: patch title include target
---
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
wt., 15 lis 2022 o 10:08 Hui Tang <tanghui20@huawei.com> napisaĆ(a): > > It will cause invalid pointer dereference to priv->cm3_base behind, > if PTR_ERR(priv->cm3_base) in mvpp2_get_sram(). > > Fixes: a59d354208a7 ("net: mvpp2: enable global flow control") > Signed-off-by: Hui Tang <tanghui20@huawei.com> > --- > v1 -> v2: patch title include target > --- > drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c > index d98f7e9a480e..c92bd1922421 100644 > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c > @@ -7421,7 +7421,7 @@ static int mvpp2_probe(struct platform_device *pdev) > dev_warn(&pdev->dev, "Fail to alloc CM3 SRAM\n"); > > /* Enable global Flow Control only if handler to SRAM not NULL */ > - if (priv->cm3_base) > + if (!IS_ERR_OR_NULL(priv->cm3_base)) > priv->global_tx_fc = true; > } > > -- > 2.17.1 > Thank you for the patch. Reviewed-by: Marcin Wojtas <mw@semihalf.com> Best regards, Marcin
On Tue, Nov 15, 2022 at 05:04:33PM +0800, Hui Tang wrote: > It will cause invalid pointer dereference to priv->cm3_base behind, > if PTR_ERR(priv->cm3_base) in mvpp2_get_sram(). As i pointed out for the MDIO driver, i wonder if this is the correct fix. mvpp2_get_sram() is probably a better place to handle this In fact, please add a devm_ioremap_resource_optional() which returns NULL if the resource does not exist, or an error code for real errors, and make drivers fail the probe on real errors. Andrew
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index d98f7e9a480e..c92bd1922421 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -7421,7 +7421,7 @@ static int mvpp2_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "Fail to alloc CM3 SRAM\n"); /* Enable global Flow Control only if handler to SRAM not NULL */ - if (priv->cm3_base) + if (!IS_ERR_OR_NULL(priv->cm3_base)) priv->global_tx_fc = true; }