1 |
From 4488f5895f0b320ea402c979a1fd58cfebe83128 Mon Sep 17 00:00:00 2001 |
2 |
From: YueHaibing <yuehaibing@huawei.com> |
3 |
Date: Tue, 4 Sep 2018 02:56:26 +0000 |
4 |
Subject: [PATCH 064/145] failover: Add missing check to validate 'slave_dev' |
5 |
in net_failover_slave_unregister |
6 |
|
7 |
[ Upstream commit 9e7e6cabf371cc008cb2244a04c012b516753693 ] |
8 |
|
9 |
Fixes gcc '-Wunused-but-set-variable' warning: |
10 |
|
11 |
drivers/net/net_failover.c: In function 'net_failover_slave_unregister': |
12 |
drivers/net/net_failover.c:598:35: warning: |
13 |
variable 'primary_dev' set but not used [-Wunused-but-set-variable] |
14 |
|
15 |
There should check the validity of 'slave_dev'. |
16 |
|
17 |
Fixes: cfc80d9a1163 ("net: Introduce net_failover driver") |
18 |
|
19 |
Signed-off-by: YueHaibing <yuehaibing@huawei.com> |
20 |
Acked-by: Sridhar Samudrala <sridhar.samudrala@intel.com> |
21 |
Signed-off-by: David S. Miller <davem@davemloft.net> |
22 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
23 |
--- |
24 |
drivers/net/net_failover.c | 3 +++ |
25 |
1 file changed, 3 insertions(+) |
26 |
|
27 |
diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c |
28 |
index 7ae1856d1f18..5a749dc25bec 100644 |
29 |
--- a/drivers/net/net_failover.c |
30 |
+++ b/drivers/net/net_failover.c |
31 |
@@ -603,6 +603,9 @@ static int net_failover_slave_unregister(struct net_device *slave_dev, |
32 |
primary_dev = rtnl_dereference(nfo_info->primary_dev); |
33 |
standby_dev = rtnl_dereference(nfo_info->standby_dev); |
34 |
|
35 |
+ if (WARN_ON_ONCE(slave_dev != primary_dev && slave_dev != standby_dev)) |
36 |
+ return -ENODEV; |
37 |
+ |
38 |
vlan_vids_del_by_dev(slave_dev, failover_dev); |
39 |
dev_uc_unsync(slave_dev, failover_dev); |
40 |
dev_mc_unsync(slave_dev, failover_dev); |
41 |
-- |
42 |
2.19.1 |
43 |
|