diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 68c9d1833b95..c67abda5d639 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -981,8 +981,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, if (nlk->ngroups == 0) groups = 0; - else - groups &= (1ULL << nlk->ngroups) - 1; + else if (nlk->ngroups < 8*sizeof(groups)) + groups &= (1UL << nlk->ngroups) - 1; bound = nlk->bound; if (bound) {