Subject: [PATCH AUTOSEL 5.10 27/27] devlink: health: Fix nla_nest_end in error flow

From: Sasha Levin <[email-masked]>
Date: Sun, 26 Feb 2023 09:50:14 -0500

From: Moshe Shemesh <[email-masked]>

[ Upstream commit bfd4e6a5dbbc12f77620602e764ac940ccb159de ]

devlink_nl_health_reporter_fill() error flow calls nla_nest_end(). Fix
it to call nla_nest_cancel() instead.

Note the bug is harmless as genlmsg_cancel() cancel the entire message,
so no fixes tag added.

Signed-off-by: Moshe Shemesh <[email-masked]>
Reviewed-by: Jiri Pirko <[email-masked]>
Reviewed-by: Jakub Kicinski <[email-masked]>
Signed-off-by: Jakub Kicinski <[email-masked]>
Signed-off-by: Sasha Levin <[email-masked]>
---
 net/core/devlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/devlink.c b/net/core/devlink.c
index 72047750dcd96..4fccd27a6082e 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6093,7 +6093,7 @@ devlink_nl_health_reporter_fill(struct sk_buff *msg,
 	return 0;
 
 reporter_nest_cancel:
-	nla_nest_end(msg, reporter_attr);
+	nla_nest_cancel(msg, reporter_attr);
 genlmsg_cancel:
 	genlmsg_cancel(msg, hdr);
 	return -EMSGSIZE;
-- 
2.39.0