Commit 10dfdc69 authored by Harald Welte's avatar Harald Welte Committed by Arnaldo Carvalho de Melo

[NETFILTER] nfnetlink: Use kzalloc

These is a cleanup patch, kzalloc can be used in a couple of cases
Signed-off-by: default avatarSamir Bellabes <sbellabes@mandriva.com>
Signed-off-by: default avatarHarald Welte <laforge@netfilter.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent 0f81eb4d
...@@ -146,11 +146,10 @@ instance_create(u_int16_t group_num, int pid) ...@@ -146,11 +146,10 @@ instance_create(u_int16_t group_num, int pid)
goto out_unlock; goto out_unlock;
} }
inst = kmalloc(sizeof(*inst), GFP_ATOMIC); inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
if (!inst) if (!inst)
goto out_unlock; goto out_unlock;
memset(inst, 0, sizeof(*inst));
INIT_HLIST_NODE(&inst->hlist); INIT_HLIST_NODE(&inst->hlist);
inst->lock = SPIN_LOCK_UNLOCKED; inst->lock = SPIN_LOCK_UNLOCKED;
/* needs to be two, since we _put() after creation */ /* needs to be two, since we _put() after creation */
...@@ -962,10 +961,9 @@ static int nful_open(struct inode *inode, struct file *file) ...@@ -962,10 +961,9 @@ static int nful_open(struct inode *inode, struct file *file)
struct iter_state *is; struct iter_state *is;
int ret; int ret;
is = kmalloc(sizeof(*is), GFP_KERNEL); is = kzalloc(sizeof(*is), GFP_KERNEL);
if (!is) if (!is)
return -ENOMEM; return -ENOMEM;
memset(is, 0, sizeof(*is));
ret = seq_open(file, &nful_seq_ops); ret = seq_open(file, &nful_seq_ops);
if (ret < 0) if (ret < 0)
goto out_free; goto out_free;
......
...@@ -136,11 +136,10 @@ instance_create(u_int16_t queue_num, int pid) ...@@ -136,11 +136,10 @@ instance_create(u_int16_t queue_num, int pid)
goto out_unlock; goto out_unlock;
} }
inst = kmalloc(sizeof(*inst), GFP_ATOMIC); inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
if (!inst) if (!inst)
goto out_unlock; goto out_unlock;
memset(inst, 0, sizeof(*inst));
inst->queue_num = queue_num; inst->queue_num = queue_num;
inst->peer_pid = pid; inst->peer_pid = pid;
inst->queue_maxlen = NFQNL_QMAX_DEFAULT; inst->queue_maxlen = NFQNL_QMAX_DEFAULT;
...@@ -1036,10 +1035,9 @@ static int nfqnl_open(struct inode *inode, struct file *file) ...@@ -1036,10 +1035,9 @@ static int nfqnl_open(struct inode *inode, struct file *file)
struct iter_state *is; struct iter_state *is;
int ret; int ret;
is = kmalloc(sizeof(*is), GFP_KERNEL); is = kzalloc(sizeof(*is), GFP_KERNEL);
if (!is) if (!is)
return -ENOMEM; return -ENOMEM;
memset(is, 0, sizeof(*is));
ret = seq_open(file, &nfqnl_seq_ops); ret = seq_open(file, &nfqnl_seq_ops);
if (ret < 0) if (ret < 0)
goto out_free; goto out_free;
......
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