ipvs: add a 'default' case in do_ip_vs_set_ctl()
authorLi Qiong <liqiong@nfschina.com>
Mon, 12 Dec 2022 07:43:51 +0000 (15:43 +0800)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 13 Dec 2022 11:23:18 +0000 (12:23 +0100)
It is better to return the default switch case with
'-EINVAL', in case new commands are added. otherwise,
return a uninitialized value of ret.

Signed-off-by: Li Qiong <liqiong@nfschina.com>
Reviewed-by: Simon Horman <horms@verge.net.au>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/ipvs/ip_vs_ctl.c

index 988222fff9f025a6635b66e47ad518e67e34c182..97f6a1c8933acd99b786c61fe02aba516ab69e72 100644 (file)
@@ -2590,6 +2590,11 @@ do_ip_vs_set_ctl(struct sock *sk, int cmd, sockptr_t ptr, unsigned int len)
                break;
        case IP_VS_SO_SET_DELDEST:
                ret = ip_vs_del_dest(svc, &udest);
+               break;
+       default:
+               WARN_ON_ONCE(1);
+               ret = -EINVAL;
+               break;
        }
 
   out_unlock: