[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241025091139.230117-1-hanchunchao@inspur.com>
Date: Fri, 25 Oct 2024 17:11:39 +0800
From: Charles Han <hanchunchao@...pur.com>
To: <rogerq@...nel.org>, <andrew+netdev@...n.ch>, <davem@...emloft.net>,
<edumazet@...gle.com>, <kuba@...nel.org>, <pabeni@...hat.com>
CC: <jpanis@...libre.com>, <dan.carpenter@...aro.org>,
<grygorii.strashko@...com>, <u.kleine-koenig@...libre.com>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>, Charles Han
<hanchunchao@...pur.com>
Subject: [PATCH] net: ethernet: ti: am65-cpsw: fix NULL deref check in am65_cpsw_nuss_probe
In am65_cpsw_nuss_probe() devm_kzalloc() may return NULL but this
returned value is not checked.
Fixes: 1af3cb3702d0 ("net: ethernet: ti: am65-cpsw: Fix hardware switch mode on suspend/resume")
Signed-off-by: Charles Han <hanchunchao@...pur.com>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 6201a09fa5f0..7af7542093e8 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -3528,6 +3528,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
common->ale_context = devm_kzalloc(dev,
ale_entries * ALE_ENTRY_WORDS * sizeof(u32),
GFP_KERNEL);
+ if (!common->ale_context)
+ return -ENOMEM;
+
ret = am65_cpsw_init_cpts(common);
if (ret)
goto err_of_clear;
--
2.31.1
Powered by blists - more mailing lists