* [PATCH] rnbd-clt: Use common error handling code in rnbd_get_iu()
@ 2026-06-10 19:03 Markus Elfring
2026-06-12 9:39 ` Haris Iqbal
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2026-06-10 19:03 UTC (permalink / raw)
To: linux-block, Jack Wang, Jens Axboe, Md. Haris Iqbal; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 10 Jun 2026 20:58:47 +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/block/rnbd/rnbd-clt.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
index 4d6725a0035e..d8e3f145ee2f 100644
--- a/drivers/block/rnbd/rnbd-clt.c
+++ b/drivers/block/rnbd/rnbd-clt.c
@@ -329,10 +329,8 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess,
return NULL;
permit = rnbd_get_permit(sess, con_type, wait);
- if (!permit) {
- kfree(iu);
- return NULL;
- }
+ if (!permit)
+ goto free_iu;
iu->permit = permit;
/*
@@ -349,6 +347,7 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess,
if (sg_alloc_table(&iu->sgt, 1, GFP_KERNEL)) {
rnbd_put_permit(sess, permit);
+free_iu:
kfree(iu);
return NULL;
}
--
2.54.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] rnbd-clt: Use common error handling code in rnbd_get_iu()
2026-06-10 19:03 [PATCH] rnbd-clt: Use common error handling code in rnbd_get_iu() Markus Elfring
@ 2026-06-12 9:39 ` Haris Iqbal
0 siblings, 0 replies; 2+ messages in thread
From: Haris Iqbal @ 2026-06-12 9:39 UTC (permalink / raw)
To: Markus Elfring; +Cc: linux-block, Jack Wang, Jens Axboe, LKML, kernel-janitors
On Wed, Jun 10, 2026 at 9:03 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 10 Jun 2026 20:58:47 +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/block/rnbd/rnbd-clt.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/rnbd/rnbd-clt.c b/drivers/block/rnbd/rnbd-clt.c
> index 4d6725a0035e..d8e3f145ee2f 100644
> --- a/drivers/block/rnbd/rnbd-clt.c
> +++ b/drivers/block/rnbd/rnbd-clt.c
> @@ -329,10 +329,8 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess,
> return NULL;
>
> permit = rnbd_get_permit(sess, con_type, wait);
> - if (!permit) {
> - kfree(iu);
> - return NULL;
> - }
> + if (!permit)
> + goto free_iu;
>
> iu->permit = permit;
> /*
> @@ -349,6 +347,7 @@ static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess,
>
> if (sg_alloc_table(&iu->sgt, 1, GFP_KERNEL)) {
> rnbd_put_permit(sess, permit);
> +free_iu:
Thanks for the patch.
It does what it mentioned in the commit description, but maybe we do
not need to do this?
If there was a kfree before the last "return iu;", it would have made
more sense. But jumping to the middle of a conditional block to reuse
the free and return seems forced.
> kfree(iu);
> return NULL;
> }
> --
> 2.54.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-12 9:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-10 19:03 [PATCH] rnbd-clt: Use common error handling code in rnbd_get_iu() Markus Elfring
2026-06-12 9:39 ` Haris Iqbal
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®