Skip to content

Commit

Permalink
bridge: Switch to bitmap_zalloc()
Browse files Browse the repository at this point in the history
Switch to bitmap_zalloc() to show clearly what we are allocating.
Besides that it returns pointer of bitmap type instead of opaque void *.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andy Shevchenko authored and David S. Miller committed Sep 1, 2018
1 parent 0340376 commit 459479d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions net/bridge/br_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,7 @@ static int find_portno(struct net_bridge *br)
struct net_bridge_port *p;
unsigned long *inuse;

inuse = kcalloc(BITS_TO_LONGS(BR_MAX_PORTS), sizeof(unsigned long),
GFP_KERNEL);
inuse = bitmap_zalloc(BR_MAX_PORTS, GFP_KERNEL);
if (!inuse)
return -ENOMEM;

Expand All @@ -404,7 +403,7 @@ static int find_portno(struct net_bridge *br)
set_bit(p->port_no, inuse);
}
index = find_first_zero_bit(inuse, BR_MAX_PORTS);
kfree(inuse);
bitmap_free(inuse);

return (index >= BR_MAX_PORTS) ? -EXFULL : index;
}
Expand Down
5 changes: 2 additions & 3 deletions net/bridge/br_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,7 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid)
return 0;
}

changed = kcalloc(BITS_TO_LONGS(BR_MAX_PORTS), sizeof(unsigned long),
GFP_KERNEL);
changed = bitmap_zalloc(BR_MAX_PORTS, GFP_KERNEL);
if (!changed)
return -ENOMEM;

Expand Down Expand Up @@ -925,7 +924,7 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid)
br->default_pvid = pvid;

out:
kfree(changed);
bitmap_free(changed);
return err;

err_port:
Expand Down

0 comments on commit 459479d

Please sign in to comment.