* [PATCH] firmware: arm_scmi: Use common error handling code in __scmi_device_create()
@ 2026-06-11 8:34 Markus Elfring
2026-06-11 11:20 ` Cristian Marussi
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-11 8:34 UTC (permalink / raw)
To: arm-scmi, linux-arm-kernel, Cristian Marussi, Sudeep Holla
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 11 Jun 2026 10:27:45 +0200
Use an additional label so that a bit of exception handling can be better
reused at the end of an if branch.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/firmware/arm_scmi/bus.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index 793be9eabaed..8c20ed1a8243 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -450,14 +450,13 @@ __scmi_device_create(struct device_node *np, struct device *parent,
return NULL;
scmi_dev->name = kstrdup_const(name ?: "unknown", GFP_KERNEL);
- if (!scmi_dev->name) {
- kfree(scmi_dev);
- return NULL;
- }
+ if (!scmi_dev->name)
+ goto free_scmi_dev;
id = ida_alloc_min(&scmi_bus_id, 1, GFP_KERNEL);
if (id < 0) {
kfree_const(scmi_dev->name);
+free_scmi_dev:
kfree(scmi_dev);
return NULL;
}
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] firmware: arm_scmi: Use common error handling code in __scmi_device_create()
2026-06-11 8:34 [PATCH] firmware: arm_scmi: Use common error handling code in __scmi_device_create() Markus Elfring
@ 2026-06-11 11:20 ` Cristian Marussi
0 siblings, 0 replies; 2+ messages in thread
From: Cristian Marussi @ 2026-06-11 11:20 UTC (permalink / raw)
To: Markus Elfring
Cc: arm-scmi, linux-arm-kernel, Cristian Marussi, Sudeep Holla, LKML,
kernel-janitors
On Thu, Jun 11, 2026 at 10:34:52AM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 11 Jun 2026 10:27:45 +0200
>
> Use an additional label so that a bit of exception handling can be better
> reused at the end of an if branch.
>
Hi,
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/firmware/arm_scmi/bus.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
> index 793be9eabaed..8c20ed1a8243 100644
> --- a/drivers/firmware/arm_scmi/bus.c
> +++ b/drivers/firmware/arm_scmi/bus.c
> @@ -450,14 +450,13 @@ __scmi_device_create(struct device_node *np, struct device *parent,
> return NULL;
>
> scmi_dev->name = kstrdup_const(name ?: "unknown", GFP_KERNEL);
> - if (!scmi_dev->name) {
> - kfree(scmi_dev);
> - return NULL;
> - }
> + if (!scmi_dev->name)
> + goto free_scmi_dev;
>
> id = ida_alloc_min(&scmi_bus_id, 1, GFP_KERNEL);
> if (id < 0) {
> kfree_const(scmi_dev->name);
> +free_scmi_dev:
> kfree(scmi_dev);
I can understand the aim, but jumping in the middle of another block
just to reuse the cleanup statement is far less readable (and ugly)
Cleanup handlers probably a better solution here...but I have NOT looked
at all the sorrounding code here recently...so I maybe wrong and keeping
the current code could be even bette.
Thanks,
Cristian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-11 11:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-11 8:34 [PATCH] firmware: arm_scmi: Use common error handling code in __scmi_device_create() Markus Elfring
2026-06-11 11:20 ` Cristian Marussi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox