linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fpga: dfl: fme: Return directly after a failed devm_kasprintf() call in fme_perf_pmu_register()
@ 2024-01-27 14:55 Markus Elfring
  2024-01-30 10:03 ` Xu Yilun
  2024-01-30 15:49 ` Dan Carpenter
  0 siblings, 2 replies; 13+ messages in thread
From: Markus Elfring @ 2024-01-27 14:55 UTC (permalink / raw)
  To: linux-fpga, kernel-janitors, Greg Kroah-Hartman, Luwei Kang,
	Moritz Fischer, Tom Rix, Wu Hao, Xu Yilun
  Cc: LKML, Kunwu Chan

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 27 Jan 2024 15:43:42 +0100

The result from a call of the function “devm_kasprintf” was passed to
a subsequent function call without checking for a null pointer before
(according to a memory allocation failure).
This issue was detected by using the Coccinelle software.

Thus return directly after a failed devm_kasprintf() call.

Fixes: 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-02-02  7:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-27 14:55 [PATCH] fpga: dfl: fme: Return directly after a failed devm_kasprintf() call in fme_perf_pmu_register() Markus Elfring
2024-01-30 10:03 ` Xu Yilun
2024-01-30 10:27   ` Xu Yilun
2024-01-30 10:48     ` Markus Elfring
2024-01-30 13:59       ` Xu Yilun
2024-01-31  7:42         ` Markus Elfring
2024-01-30 14:11     ` [PATCH] " Greg Kroah-Hartman
2024-01-30 15:49 ` Dan Carpenter
2024-01-30 17:09   ` Markus Elfring
2024-01-30 17:13     ` Greg Kroah-Hartman
2024-01-31  5:43     ` Dan Carpenter
2024-01-31  7:51       ` Markus Elfring
2024-02-02  7:57   ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).