----- yuehaib...@huawei.com wrote:

> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/net/net_failover.c: In function
> 'net_failover_slave_unregister':
> drivers/net/net_failover.c:598:35: warning:
>  variable 'primary_dev' set but not used [-Wunused-but-set-variable]
> 
> There should check the validity of 'slave_dev'.
> 
> Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")
> 
> Signed-off-by: YueHaibing <yuehaib...@huawei.com>
> ---
> v2: use WARN_ON_ONCE as Liran Alon suggested
> ---
>  drivers/net/net_failover.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
> index 7ae1856..5a749dc 100644
> --- a/drivers/net/net_failover.c
> +++ b/drivers/net/net_failover.c
> @@ -603,6 +603,9 @@ static int net_failover_slave_unregister(struct
> net_device *slave_dev,
>       primary_dev = rtnl_dereference(nfo_info->primary_dev);
>       standby_dev = rtnl_dereference(nfo_info->standby_dev);
>  
> +     if (WARN_ON_ONCE(slave_dev != primary_dev && slave_dev !=
> standby_dev))
> +             return -ENODEV;
> +

I prefer to put () around different conditions but that's just a matter of 
taste.
Reviewed-by: Liran Alon <liran.a...@oracle.com>

>       vlan_vids_del_by_dev(slave_dev, failover_dev);
>       dev_uc_unsync(slave_dev, failover_dev);
>       dev_mc_unsync(slave_dev, failover_dev);

Reply via email to