From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org, drbd-dev@lists.linbit.com,
linux-block@vger.kernel.org,
"Christoph Böhmwalder" <christoph.boehmwalder@linbit.com>,
"Jens Axboe" <axboe@kernel.dk>,
"Lars Ellenberg" <lars.ellenberg@linbit.com>,
"Philipp Reisner" <philipp.reisner@linbit.com>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: [Drbd-dev] [PATCH] drbd: Fix exception handling in nla_put_drbd_cfg_context()
Date: Fri, 17 Mar 2023 18:40:35 +0100 [thread overview]
Message-ID: <8d193937-532f-959f-9b84-d911984508aa@web.de> (raw)
In-Reply-To: <f9303bdc-b1a7-be5e-56c6-dfa8232b8b55@web.de>
Date: Fri, 17 Mar 2023 18:32:05 +0100
The label “nla_put_failure” was used to jump to another pointer check
despite of the detail in the implementation of the function
“nla_put_drbd_cfg_context” that it was determined already that
the corresponding variable contained a null pointer.
* Thus return directly after a call of the function
“nla_nest_start_noflag” failed.
* Delete an extra pointer check which became unnecessary
with this refactoring.
This issue was detected by using the Coccinelle software.
Fixes: 543cc10b4cc5c60aa9fcc62705ccfb9998bf4697 ("drbd: drbd_adm_get_status needs to show some more detail")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/block/drbd/drbd_nl.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
index f49f2a5282e1..9cb947127472 100644
--- a/drivers/block/drbd/drbd_nl.c
+++ b/drivers/block/drbd/drbd_nl.c
@@ -3187,7 +3187,7 @@ static int nla_put_drbd_cfg_context(struct sk_buff *skb,
struct nlattr *nla;
nla = nla_nest_start_noflag(skb, DRBD_NLA_CFG_CONTEXT);
if (!nla)
- goto nla_put_failure;
+ return -EMSGSIZE;
if (device &&
nla_put_u32(skb, T_ctx_volume, device->vnr))
goto nla_put_failure;
@@ -3205,8 +3205,7 @@ static int nla_put_drbd_cfg_context(struct sk_buff *skb,
return 0;
nla_put_failure:
- if (nla)
- nla_nest_cancel(skb, nla);
+ nla_nest_cancel(skb, nla);
return -EMSGSIZE;
}
--
2.40.0
next parent reply other threads:[~2023-03-17 18:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <f9303bdc-b1a7-be5e-56c6-dfa8232b8b55@web.de>
2023-03-17 17:40 ` Markus Elfring [this message]
2023-03-25 14:07 ` [Drbd-dev] [PATCH resent] drbd: Fix exception handling in nla_put_drbd_cfg_context() Markus Elfring
2023-03-27 12:28 ` Christoph Böhmwalder
2023-03-27 17:26 ` [Drbd-dev] " Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8d193937-532f-959f-9b84-d911984508aa@web.de \
--to=markus.elfring@web.de \
--cc=axboe@kernel.dk \
--cc=christoph.boehmwalder@linbit.com \
--cc=cocci@inria.fr \
--cc=drbd-dev@lists.linbit.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=philipp.reisner@linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox