Commit 1b1a5bb6 authored by Hiroaki SHIMODA's avatar Hiroaki SHIMODA Committed by Luis Henriques

netlink: Properly unbind in error conditions.

commit 6251edd9 upstream.

Even if netlink_kernel_cfg::unbind is implemented the unbind() method is
not called, because cfg->unbind is omitted in __netlink_kernel_create().
And fix wrong argument of test_bit() and off by one problem.

At this point, no unbind() method is implemented, so there is no real
issue.

Fixes: 4f520900 ("netlink: have netlink per-protocol bind function return an error code.")
Signed-off-by: default avatarHiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Cc: Richard Guy Briggs <rgb@redhat.com>
Acked-by: default avatarRichard Guy Briggs <rgb@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent b828096e
......@@ -1491,7 +1491,7 @@ static void netlink_unbind(int group, long unsigned int groups,
return;
for (undo = 0; undo < group; undo++)
if (test_bit(group, &groups))
if (test_bit(undo, &groups))
nlk->netlink_unbind(undo);
}
......@@ -1543,7 +1543,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
netlink_insert(sk, net, nladdr->nl_pid) :
netlink_autobind(sock);
if (err) {
netlink_unbind(nlk->ngroups - 1, groups, nlk);
netlink_unbind(nlk->ngroups, groups, nlk);
return err;
}
}
......@@ -2563,6 +2563,7 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
nl_table[unit].module = module;
if (cfg) {
nl_table[unit].bind = cfg->bind;
nl_table[unit].unbind = cfg->unbind;
nl_table[unit].flags = cfg->flags;
if (cfg->compare)
nl_table[unit].compare = cfg->compare;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment