rnbd-clt: Use common error handling code in rnbd_get_iu()
Subsystems (3)
PATCH 1/1 rnbd-clt: Use common error handling code in rnbd_get_iu()
From: Markus Elfring <[email protected]>
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.
--- drivers/block/rnbd/rnbd-clt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/block/rnbd/rnbd-clt.c +3 -4
@@ -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 ; }
Signature · 1 line
2.54.0
Haris Iqbal
maintainerQuoted 32 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 10 Jun 2026 20:58:47 +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/block/rnbd/rnbd-clt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/block/rnbd/rnbd-clt.c +2
-4@@ -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;/*
drivers/block/rnbd/rnbd-clt.c static struct rnbd_iu *rnbd_get_iu(struct rnbd_clt_session *sess, · line 350
Quoted 4 lines
drivers/block/rnbd/rnbd-clt.c +1
-0@@ -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.
Quoted 6 lines
drivers/block/rnbd/rnbd-clt.c +0
-1kfree (iu);return NULL ; } --2.54.0