Skip to content

Commit 10dfdc6

Browse files
laf0rgeArnaldo Carvalho de Melo
authored andcommitted
[NETFILTER] nfnetlink: Use kzalloc
These is a cleanup patch, kzalloc can be used in a couple of cases Signed-off-by: Samir Bellabes <[email protected]> Signed-off-by: Harald Welte <[email protected]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 0f81eb4 commit 10dfdc6

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

net/netfilter/nfnetlink_log.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,10 @@ instance_create(u_int16_t group_num, int pid)
146146
goto out_unlock;
147147
}
148148

149-
inst = kmalloc(sizeof(*inst), GFP_ATOMIC);
149+
inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
150150
if (!inst)
151151
goto out_unlock;
152152

153-
memset(inst, 0, sizeof(*inst));
154153
INIT_HLIST_NODE(&inst->hlist);
155154
inst->lock = SPIN_LOCK_UNLOCKED;
156155
/* needs to be two, since we _put() after creation */
@@ -962,10 +961,9 @@ static int nful_open(struct inode *inode, struct file *file)
962961
struct iter_state *is;
963962
int ret;
964963

965-
is = kmalloc(sizeof(*is), GFP_KERNEL);
964+
is = kzalloc(sizeof(*is), GFP_KERNEL);
966965
if (!is)
967966
return -ENOMEM;
968-
memset(is, 0, sizeof(*is));
969967
ret = seq_open(file, &nful_seq_ops);
970968
if (ret < 0)
971969
goto out_free;

net/netfilter/nfnetlink_queue.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,10 @@ instance_create(u_int16_t queue_num, int pid)
136136
goto out_unlock;
137137
}
138138

139-
inst = kmalloc(sizeof(*inst), GFP_ATOMIC);
139+
inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
140140
if (!inst)
141141
goto out_unlock;
142142

143-
memset(inst, 0, sizeof(*inst));
144143
inst->queue_num = queue_num;
145144
inst->peer_pid = pid;
146145
inst->queue_maxlen = NFQNL_QMAX_DEFAULT;
@@ -1036,10 +1035,9 @@ static int nfqnl_open(struct inode *inode, struct file *file)
10361035
struct iter_state *is;
10371036
int ret;
10381037

1039-
is = kmalloc(sizeof(*is), GFP_KERNEL);
1038+
is = kzalloc(sizeof(*is), GFP_KERNEL);
10401039
if (!is)
10411040
return -ENOMEM;
1042-
memset(is, 0, sizeof(*is));
10431041
ret = seq_open(file, &nfqnl_seq_ops);
10441042
if (ret < 0)
10451043
goto out_free;

0 commit comments

Comments
 (0)