[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250311011653.1175840-1-chenyuan0y@gmail.com>
Date: Mon, 10 Mar 2025 20:16:53 -0500
From: Chenyuan Yang <chenyuan0y@...il.com>
To: hao.wu@...el.com,
trix@...hat.com,
mdf@...nel.org,
yilun.xu@...el.com,
richardcochran@...il.com
Cc: linux-fpga@...r.kernel.org,
linux-kernel@...r.kernel.org,
Chenyuan Yang <chenyuan0y@...il.com>
Subject: [PATCH] fpga: dfl: fme: Add NULL pointer check in fme_perf_pmu_register()
name, returned by devm_kasprintf(), could be NULL.
A pointer check is added to prevent potential NULL pointer dereference.
This is similar to the fix in commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
This issue is found by our static analysis tool.
Signed-off-by: Chenyuan Yang <chenyuan0y@...il.com>
---
drivers/fpga/dfl-fme-perf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c
index 7422d2bc6f37..db56d52411ef 100644
--- a/drivers/fpga/dfl-fme-perf.c
+++ b/drivers/fpga/dfl-fme-perf.c
@@ -925,6 +925,8 @@ static int fme_perf_pmu_register(struct platform_device *pdev,
PERF_PMU_CAP_NO_EXCLUDE;
name = devm_kasprintf(priv->dev, GFP_KERNEL, "dfl_fme%d", pdev->id);
+ if (!name)
+ return -ENOMEM;
ret = perf_pmu_register(pmu, name, -1);
if (ret)
--
2.34.1
Powered by blists - more mailing lists