[PATCH AUTOSEL 5.4 26/29] rtnetlink: Fix missing error code in rtnl_bridge_notify()

From: Sasha Levin
Date: Mon Jun 07 2021 - 12:20:59 EST


From: Jiapeng Chong <jiapeng.chong@xxxxxxxxxxxxxxxxx>

[ Upstream commit a8db57c1d285c758adc7fb43d6e2bad2554106e1 ]

The error code is missing in this code scenario, add the error code
'-EINVAL' to the return value 'err'.

Eliminate the follow smatch warning:

net/core/rtnetlink.c:4834 rtnl_bridge_notify() warn: missing error code
'err'.

Reported-by: Abaci Robot <abaci@xxxxxxxxxxxxxxxxx>
Signed-off-by: Jiapeng Chong <jiapeng.chong@xxxxxxxxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
net/core/rtnetlink.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 73c09b5864d7..bdeb169a7a99 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -4535,8 +4535,10 @@ static int rtnl_bridge_notify(struct net_device *dev)
if (err < 0)
goto errout;

- if (!skb->len)
+ if (!skb->len) {
+ err = -EINVAL;
goto errout;
+ }

rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC);
return 0;
--
2.30.2