netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] xfrm: Add error handling when nla_put_u32() returns an error
@ 2024-11-12 23:36 Everest K.C.
  2024-11-13 10:59 ` Simon Horman
  2024-11-13 14:12 ` Przemek Kitszel
  0 siblings, 2 replies; 8+ messages in thread
From: Everest K.C. @ 2024-11-12 23:36 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, edumazet, kuba, pabeni, horms
  Cc: Everest K.C., netdev, kernel-janitors, linux-kernel

Error handling is missing when call to nla_put_u32() fails.
Handle the error when the call to nla_put_u32() returns an error.

The error was reported by Coverity Scan.
Report:
CID 1601525: (#1 of 1): Unused value (UNUSED_VALUE)
returned_value: Assigning value from nla_put_u32(skb, XFRMA_SA_PCPU, x->pcpu_num)
to err here, but that stored value is overwritten before it can be used

Fixes: 1ddf9916ac09 ("xfrm: Add support for per cpu xfrm state handling.")
Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
---
 net/xfrm/xfrm_user.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index f0ee0c7a59dd..a784598cc7cf 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -2607,9 +2607,12 @@ static int build_aevent(struct sk_buff *skb, struct xfrm_state *x, const struct
 	err = xfrm_if_id_put(skb, x->if_id);
 	if (err)
 		goto out_cancel;
-	if (x->pcpu_num != UINT_MAX)
+	if (x->pcpu_num != UINT_MAX) {
 		err = nla_put_u32(skb, XFRMA_SA_PCPU, x->pcpu_num);
-
+		if (err)
+			goto out_cancel;
+	}
+
 	if (x->dir) {
 		err = nla_put_u8(skb, XFRMA_SA_DIR, x->dir);
 		if (err)
-- 
2.43.0


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

end of thread, other threads:[~2024-11-15  8:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 23:36 [PATCH][next] xfrm: Add error handling when nla_put_u32() returns an error Everest K.C.
2024-11-13 10:59 ` Simon Horman
2024-11-13 13:10   ` Dan Carpenter
2024-11-13 14:06     ` Dan Carpenter
2024-11-13 17:59     ` Simon Horman
2024-11-14 19:27   ` Everest K.C.
2024-11-15  8:07     ` Steffen Klassert
2024-11-13 14:12 ` Przemek Kitszel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).