* mandatory if CONFIG_NET=y these days
*/
+#include <linux/config.h>
#include <linux/module.h>
#include <linux/capability.h>
static void netlink_table_grab(void)
{
- write_lock_irq(&nl_table_lock);
+ write_lock_bh(&nl_table_lock);
if (atomic_read(&nl_table_users)) {
DECLARE_WAITQUEUE(wait, current);
set_current_state(TASK_UNINTERRUPTIBLE);
if (atomic_read(&nl_table_users) == 0)
break;
- write_unlock_irq(&nl_table_lock);
+ write_unlock_bh(&nl_table_lock);
schedule();
- write_lock_irq(&nl_table_lock);
+ write_lock_bh(&nl_table_lock);
}
__set_current_state(TASK_RUNNING);
static __inline__ void netlink_table_ungrab(void)
{
- write_unlock_irq(&nl_table_lock);
+ write_unlock_bh(&nl_table_lock);
wake_up(&nl_table_wait);
}
if (err)
return err;
- nlk->groups = kzalloc(NLGRPSZ(groups), GFP_KERNEL);
+ nlk->groups = kmalloc(NLGRPSZ(groups), GFP_KERNEL);
if (nlk->groups == NULL)
return -ENOMEM;
+ memset(nlk->groups, 0, NLGRPSZ(groups));
nlk->ngroups = groups;
return 0;
}
struct netlink_sock *nlk;
unsigned long *listeners = NULL;
- BUG_ON(!nl_table);
+ if (!nl_table)
+ return NULL;
if (unit<0 || unit>=MAX_LINKS)
return NULL;
struct sock *sk;
struct netlink_sock *nlk;
- cb = kzalloc(sizeof(*cb), GFP_KERNEL);
+ cb = kmalloc(sizeof(*cb), GFP_KERNEL);
if (cb == NULL)
return -ENOBUFS;
+ memset(cb, 0, sizeof(*cb));
cb->dump = dump;
cb->done = done;
cb->nlh = nlh;
struct nl_seq_iter *iter;
int err;
- iter = kzalloc(sizeof(*iter), GFP_KERNEL);
+ iter = kmalloc(sizeof(*iter), GFP_KERNEL);
if (!iter)
return -ENOMEM;
return err;
}
+ memset(iter, 0, sizeof(*iter));
seq = file->private_data;
seq->private = iter;
return 0;
if (sizeof(struct netlink_skb_parms) > sizeof(dummy_skb->cb))
netlink_skb_parms_too_large();
- nl_table = kcalloc(MAX_LINKS, sizeof(*nl_table), GFP_KERNEL);
- if (!nl_table)
- goto panic;
+ nl_table = kmalloc(sizeof(*nl_table) * MAX_LINKS, GFP_KERNEL);
+ if (!nl_table) {
+enomem:
+ printk(KERN_CRIT "netlink_init: Cannot allocate nl_table\n");
+ return -ENOMEM;
+ }
+
+ memset(nl_table, 0, sizeof(*nl_table) * MAX_LINKS);
if (num_physpages >= (128 * 1024))
max = num_physpages >> (21 - PAGE_SHIFT);
nl_pid_hash_free(nl_table[i].hash.table,
1 * sizeof(*hash->table));
kfree(nl_table);
- goto panic;
+ goto enomem;
}
memset(hash->table, 0, 1 * sizeof(*hash->table));
hash->max_shift = order;
rtnetlink_init();
out:
return err;
-panic:
- panic("netlink_init: Cannot allocate nl_table\n");
}
core_initcall(netlink_proto_init);