]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/netlink/af_netlink.c
Merge tag 'char-misc-5.6-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[linux.git] / net / netlink / af_netlink.c
index 4e31721e729360c8bf555186ab6d4aa67cb00280..edf3e285e242877d78b044bac89b4a41804b56cb 100644 (file)
@@ -1014,7 +1014,8 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
        if (nlk->netlink_bind && groups) {
                int group;
 
-               for (group = 0; group < nlk->ngroups; group++) {
+               /* nl_groups is a u32, so cap the maximum groups we can bind */
+               for (group = 0; group < BITS_PER_TYPE(u32); group++) {
                        if (!test_bit(group, &groups))
                                continue;
                        err = nlk->netlink_bind(net, group + 1);
@@ -1033,7 +1034,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
                        netlink_insert(sk, nladdr->nl_pid) :
                        netlink_autobind(sock);
                if (err) {
-                       netlink_undo_bind(nlk->ngroups, groups, sk);
+                       netlink_undo_bind(BITS_PER_TYPE(u32), groups, sk);
                        goto unlock;
                }
        }