i40e: Use common error handling code in i40e_register_auxiliary_dev()
Subsystems (4)
PATCH 1/1 i40e: Use common error handling code in i40e_register_auxiliary_dev()
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 10:02:58 +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.
--- drivers/net/ethernet/intel/i40e/i40e_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_client.c +4 -4
@@ -304,15 +304,15 @@ static int i40e_register_auxiliary_dev(struct i40e_info *ldev, const char *name) ldev->aux_dev = aux_dev; ret =ida_alloc (&i40e_client_ida,GFP_KERNEL ); -if (ret <0 ) { -kfree (i40e_aux_dev); -return ret; - } +if (ret <0 ) + goto free_aux_dev; + aux_dev->id = ret; ret =auxiliary_device_init (aux_dev);if (ret <0 ) {ida_free (&i40e_client_ida, aux_dev->id); +free_aux_dev:kfree (i40e_aux_dev);return ret; }
Signature · 1 line
2.54.0
Quoted 22 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 10:02:58 +0200[...]
drivers/net/ethernet/intel/i40e/i40e_client.c +0
-0@@ -304,15 +304,15 @@ static int i40e_register_auxiliary_dev(struct i40e_info *ldev, const char *name) ldev->aux_dev = aux_dev;
ret =ida_alloc(&i40e_client_ida, GFP_KERNEL);drivers/net/ethernet/intel/i40e/i40e_client.c +3
-4-if (ret <0 ) { -kfree (i40e_aux_dev); -return ret; - } +if (ret <0 ) + goto free_aux_dev; +
Quoted 8 lines
aux_dev->id= ret;
ret =auxiliary_device_init(aux_dev); if (ret < 0) {ida_free(&i40e_client_ida, aux_dev->id); +free_aux_dev:
kfree(i40e_aux_dev);
return ret;
why do you do this? There's no functional change, right? is it just readability?
Thanks
Manuel
Quoted 15 lines
Quoted 15 lines
+++
b/drivers/net/ethernet/intel/i40e/i40e_client.c(quoted diff) +0
-0@@ -304,15 +304,15 @@ static int i40e_register_auxiliary_dev(struct i40e_info *ldev, const char *name) ldev->aux_dev = aux_dev;
ret =ida_alloc(&i40e_client_ida, GFP_KERNEL);drivers/net/ethernet/intel/i40e/i40e_client.c +3
-4-if (ret <0 ) { -kfree (i40e_aux_dev); -return ret; - } +if (ret <0 ) + goto free_aux_dev; +
aux_dev->id= ret;
Quoted 8 lines
Quoted 6 lines
ret =
auxiliary_device_init(aux_dev); if (ret < 0) {ida_free(&i40e_client_ida, aux_dev->id); +free_aux_dev:
kfree(i40e_aux_dev);
return ret;why do you do this? There's no functional change, right? is it just readability?
Please take another look at corresponding information sources.
* Centralized exiting of functions
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v7.1-rc7#n526
Would you like to increase the application of scope-based resource management?
Regards,
Markus
Quoted 43 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Markus Elfring
Sent: Wednesday, June 10, 2026 10:20 AM
To: [email protected]; [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Shiraz Saleem <[email protected]>; Nguyen, Anthony L <[email protected]>
Cc: LKML <[email protected]>; kernel- [email protected]
Subject: [Intel-wired-lan] [PATCH net-next] i40e: Use common error handling code ini40e_register_auxiliary_dev()From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 10:02:58 +0200Use 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 <[email protected]>--- drivers/net/ethernet/intel/i40e/i40e_client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/i40e/i40e_client.c +0
-2@@ -304,15 +304,15 @@ static int i40e_register_auxiliary_dev(struct i40e_info *ldev, const char *name) ldev->aux_dev = aux_dev; ret =ida_alloc (&i40e_client_ida,GFP_KERNEL ); -if (ret <0 ) { -kfree (i40e_aux_dev);
drivers/net/ethernet/intel/i40e/i40e_client.c static int i40e_register_auxiliary_dev(struct · line 315
Quoted 10 lines
drivers/net/ethernet/intel/i40e/i40e_client.c +3
-2-return ret; - } +if (ret <0 ) + goto free_aux_dev; + aux_dev->id = ret; ret =auxiliary_device_init (aux_dev);if (ret <0 ) {ida_free (&i40e_client_ida, aux_dev->id);
It's not linux kernel error handling.
Please, either leave the original code as-is — the two-line duplication is not a real problem. Or submit a proper two-label refactor with a clear commit message.
Quoted 6 lines
drivers/net/ethernet/intel/i40e/i40e_client.c +1
-0+free_aux_dev:kfree (i40e_aux_dev);return ret;}
--
2.54.0
From: Markus Elfring <[email protected]>
Sent: Wednesday, June 10, 2026 10:20 AM
Quoted 9 lines
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 10:02:58 +0200Use 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 <[email protected]>
Hi,
Do we really need patches like this one? It's pointless