mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nfsd: Use common error handling code in svc_export_alloc()
@ 2026-06-11 12:11 Markus Elfring
  2026-06-11 12:28 ` Jeff Layton
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-11 12:11 UTC (permalink / raw)
  To: linux-nfs, Chuck Lever, Dai Ngo, Jeff Layton, Neil Brown,
	Olga Kornievskaia, Tom Talpey
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 11 Jun 2026 14:03:48 +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>
---
 fs/nfsd/export.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index eb020054f9a3..bb106733f3ec 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1589,13 +1589,12 @@ static struct cache_head *svc_export_alloc(void)
 		return NULL;
 
 	i->ex_stats = kmalloc_obj(*(i->ex_stats));
-	if (!i->ex_stats) {
-		kfree(i);
-		return NULL;
-	}
+	if (!i->ex_stats)
+		goto free_export;
 
 	if (export_stats_init(i->ex_stats)) {
 		kfree(i->ex_stats);
+free_export:
 		kfree(i);
 		return NULL;
 	}
-- 
2.54.0


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

* Re: [PATCH] nfsd: Use common error handling code in svc_export_alloc()
  2026-06-11 12:11 [PATCH] nfsd: Use common error handling code in svc_export_alloc() Markus Elfring
@ 2026-06-11 12:28 ` Jeff Layton
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2026-06-11 12:28 UTC (permalink / raw)
  To: Markus Elfring, linux-nfs, Chuck Lever, Dai Ngo, Neil Brown,
	Olga Kornievskaia, Tom Talpey
  Cc: LKML, kernel-janitors

On Thu, 2026-06-11 at 14:11 +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 11 Jun 2026 14:03:48 +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>
> ---
>  fs/nfsd/export.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index eb020054f9a3..bb106733f3ec 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -1589,13 +1589,12 @@ static struct cache_head *svc_export_alloc(void)
>  		return NULL;
>  
>  	i->ex_stats = kmalloc_obj(*(i->ex_stats));
> -	if (!i->ex_stats) {
> -		kfree(i);
> -		return NULL;
> -	}
> +	if (!i->ex_stats)
> +		goto free_export;
>  
>  	if (export_stats_init(i->ex_stats)) {
>  		kfree(i->ex_stats);
> +free_export:
>  		kfree(i);
>  		return NULL;
>  	}

I'm not a fan of this patch. I mean, it's legal and all, but sticking a
goto label in the middle of a if block makes for messy-looking and hard
to reason about code.

-- 
Jeff Layton <jlayton@kernel.org>

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

end of thread, other threads:[~2026-06-11 12:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-11 12:11 [PATCH] nfsd: Use common error handling code in svc_export_alloc() Markus Elfring
2026-06-11 12:28 ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®