Skip to contentSkip to conversation

fpga: dfl: fme: Return directly after a failed devm_kasprintf() call in fme_perf_pmu_register()

PATCH In review Markus Elfring 4 participants 13 messages Jan 27, 2024 – Feb 2, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga: dfl: fme: Return directly after a failed devm_kasprintf() call in fme_perf_pmu_register()

From: Markus Elfring <[email protected]>
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")
---
 drivers/fpga/dfl-fme-perf.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/fpga/dfl-fme-perf.c +2 -0
index 7422d2bc6f37..db56d52411ef 100644
@@ -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

Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Markus Elfring

From: Markus Elfring <[email protected]>
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.

Quoted 4 lines

Thus return directly after a failed devm_kasprintf() call.

Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")
Quoted 21 lines
---
 drivers/fpga/dfl-fme-perf.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/fpga/dfl-fme-perf.c +2 -1
index 7422d2bc6f37..db56d52411ef 100644
@@ -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

#2 lore raw
Quoted 3 lines · Xu Yilun
Quoted 2 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2024 15:43:42 +0100

Sorry, something to fix.

Please shorten your shortlog to less than 75 chars. Please refer to Documentation/process/submitting-patches.rst

Quoted 9 lines
Quoted 9 lines

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")

One more char of sha.

Please use checkpatch to verify.

Thanks,
Yilun

Quoted 26 lines
Quoted 1 line
Quoted 21 lines
---
 drivers/fpga/dfl-fme-perf.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/fpga/dfl-fme-perf.c +2 -1
index 7422d2bc6f37..db56d52411ef 100644
@@ -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

#4 lore raw
Quoted 8 lines · Markus Elfring
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

Thus return directly after a failed devm_kasprintf() call.

Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")

One more char of sha.

There are different preferences involved.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.8-rc2#n109

Ah, I mean you use 13 chars, but 12 chars is better. Also the doc doens't seem to enforce 12 chars, but checkpatch warns on that. So just follow the 12 chars style.

Thanks,
Yilun

Quoted 3 lines

Regards,
Markus

#6 lore raw
In reply to Xu Yilun
Quoted 18 lines · Xu Yilun
Quoted 3 lines · Xu Yilun
Quoted 2 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 27 Jan 2024 15:43:42 +0100

Sorry, something to fix.

Please shorten your shortlog to less than 75 chars. Please refer to Documentation/process/submitting-patches.rst

Quoted 8 lines
Quoted 8 lines

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.

Quoted 8 lines
Quoted 1 line
Quoted 1 line
Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")

One more char of sha.

Please use checkpatch to verify.

Thanks,
Yilun

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless review comment to a patch submission on a Linux kernel developer mailing list. I strongly suggest that you not do this anymore. Please do not bother developers who are actively working to produce patches and features with comments that, in the end, are a waste of time.

Patch submitter, please ignore Markus's suggestion; you do not need to follow it at all. The person/bot/AI that sent it is being ignored by almost all Linux kernel maintainers for having a persistent pattern of behavior of producing distracting and pointless commentary, and inability to adapt to feedback. Please feel free to also ignore emails from them.

thanks,

greg k-h's patch email bot

#7 lore raw
In reply to Markus Elfring
Quoted 11 lines · Markus Elfring

From: Markus Elfring <[email protected]>
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")

This basically doesn't affect runtime because perf_pmu_register() checks for NULL so no need for a Fixes tag.

regards,
dan carpenter

#8 lore raw
Quoted 6 lines
Quoted 3 lines

Thus return directly after a failed devm_kasprintf() call.

Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")

This basically doesn't affect runtime because perf_pmu_register() checks for NULL so no need for a Fixes tag.

I suggest to clarify this view a bit more also according to statements like the following.

1. https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11532
perf_pmu_register:
…

	pmu->name = name;

…

2. https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11472
pmu_dev_alloc:
…

	ret = dev_set_name(pmu->dev, "%s", pmu->name);

…

Regards,
Markus

#9 lore raw
Quoted 18 lines · Markus Elfring
Quoted 6 lines
Quoted 3 lines

Thus return directly after a failed devm_kasprintf() call.

Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")

This basically doesn't affect runtime because perf_pmu_register() checks for NULL so no need for a Fixes tag.

I suggest to clarify this view a bit more also according to statements like the following.

1. https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11532
perf_pmu_register:

   …
	pmu->name = name;
   …

2. https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11472
pmu_dev_alloc:

Quoted 7 lines
   …
	ret = dev_set_name(pmu->dev, "%s", pmu->name);
   …

Regards,
Markus

Hi,

This is the semi-friendly patch-bot of Greg Kroah-Hartman.

Markus, you seem to have sent a nonsensical or otherwise pointless review comment to a patch submission on a Linux kernel developer mailing list. I strongly suggest that you not do this anymore. Please do not bother developers who are actively working to produce patches and features with comments that, in the end, are a waste of time.

thanks,

greg k-h's patch email bot

#10 lore raw
In reply to Markus Elfring
Quoted 7 lines · Markus Elfring
Quoted 6 lines
Quoted 3 lines

Thus return directly after a failed devm_kasprintf() call.

Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")

This basically doesn't affect runtime because perf_pmu_register() checks for NULL so no need for a Fixes tag.

Quoted 8 lines

I suggest to clarify this view a bit more also according to statements like the following.

1. https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11532
perf_pmu_register:

   …
	pmu->name = name;
   …

The check is right before that on line 11527.

https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11527

regards,
dan carpenter

#12 lore raw
In reply to Dan Carpenter
Quoted 5 lines
Quoted 3 lines

Thus return directly after a failed devm_kasprintf() call.

Fixes 724142f8c42a7 ("fpga: dfl: fme: add performance reporting support")

This basically doesn't affect runtime because perf_pmu_register() checks for NULL

https://elixir.bootlin.com/linux/v6.8-rc2/source/kernel/events/core.c#L11527

Do you prefer the usage of the error code “-ENOMEM” instead of “-EINVAL” as an indication for a failed memory allocation?

Quoted 1 line

so no need for a Fixes tag.

Does the selection of a more appropriate error code qualify for this tag?

Regards,
Markus