Skip to content

Commit 6251edd

Browse files
hiroa-kidavem330
authored andcommitted
netlink: Properly unbind in error conditions.
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: 4f52090 ("netlink: have netlink per-protocol bind function return an error code.") Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com> Cc: Richard Guy Briggs <rgb@redhat.com> Acked-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cca04b2 commit 6251edd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎net/netlink/af_netlink.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ static void netlink_unbind(int group, long unsigned int groups,
14401440
return;
14411441

14421442
for (undo = 0; undo < group; undo++)
1443-
if (test_bit(group, &groups))
1443+
if (test_bit(undo, &groups))
14441444
nlk->netlink_unbind(undo);
14451445
}
14461446

@@ -1492,7 +1492,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
14921492
netlink_insert(sk, net, nladdr->nl_pid) :
14931493
netlink_autobind(sock);
14941494
if (err) {
1495-
netlink_unbind(nlk->ngroups - 1, groups, nlk);
1495+
netlink_unbind(nlk->ngroups, groups, nlk);
14961496
return err;
14971497
}
14981498
}
@@ -2509,6 +2509,7 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
25092509
nl_table[unit].module = module;
25102510
if (cfg) {
25112511
nl_table[unit].bind = cfg->bind;
2512+
nl_table[unit].unbind = cfg->unbind;
25122513
nl_table[unit].flags = cfg->flags;
25132514
if (cfg->compare)
25142515
nl_table[unit].compare = cfg->compare;

0 commit comments

Comments
 (0)