Skip to contentSkip to conversation

NETFILTER nfnetlink: Use kzalloc

PATCH In review Samir Bellabes 2 participants 2 messages Oct 28, 2005 – Nov 3, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NETFILTER nfnetlink: Use kzalloc

Hi Harald,

Please consider this cleanup patch.

thanks,

Samir

tree 3c6bf70654e1453b5808587f4436f54083de73ba
parent dcab5e1eeccf5e226c771ecc013631cde157435f
author Samir Bellabes <[email protected]> 1130434537 +0200 committer Samir Bellabes <[email protected]> 1130434537 +0200

[PATCH] NETFILTER nfnetlink: Use kzalloc

These are cleanup patches, kzalloc can be use here.

------------------------------------------------------------------------------

 nfnetlink_log.c   |    6 ++----
 nfnetlink_queue.c |    6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

------------------------------------------------------------------------------

net/netfilter/nfnetlink_log.c +2 -4
@@ -146,11 +146,10 @@ instance_create(u_int16_t group_num, int
 		goto out_unlock;
 	}
 
-	inst = kmalloc(sizeof(*inst), GFP_ATOMIC);
+	inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
 	if (!inst)
 		goto out_unlock;
 
-	memset(inst, 0, sizeof(*inst));
 	INIT_HLIST_NODE(&inst->hlist);
 	inst->lock = SPIN_LOCK_UNLOCKED;
 	/* needs to be two, since we _put() after creation */
@@ -962,10 +961,9 @@ static int nful_open(struct inode *inode
 	struct iter_state *is;
 	int ret;
 
-	is = kmalloc(sizeof(*is), GFP_KERNEL);
+	is = kzalloc(sizeof(*is), GFP_KERNEL);
 	if (!is)
 		return -ENOMEM;
-	memset(is, 0, sizeof(*is));
 	ret = seq_open(file, &nful_seq_ops);
 	if (ret < 0)
 		goto out_free;
net/netfilter/nfnetlink_queue.c +2 -4
@@ -136,11 +136,10 @@ instance_create(u_int16_t queue_num, int
 		goto out_unlock;
 	}
 
-	inst = kmalloc(sizeof(*inst), GFP_ATOMIC);
+	inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
 	if (!inst)
 		goto out_unlock;
 
-	memset(inst, 0, sizeof(*inst));
 	inst->queue_num = queue_num;
 	inst->peer_pid = pid;
 	inst->queue_maxlen = NFQNL_QMAX_DEFAULT;
@@ -1036,10 +1035,9 @@ static int nfqnl_open(struct inode *inod
 	struct iter_state *is;
 	int ret;
 
-	is = kmalloc(sizeof(*is), GFP_KERNEL);
+	is = kzalloc(sizeof(*is), GFP_KERNEL);
 	if (!is)
 		return -ENOMEM;
-	memset(is, 0, sizeof(*is));
 	ret = seq_open(file, &nfqnl_seq_ops);
 	if (ret < 0)
 		goto out_free;
#1 lore raw
Quoted 3 lines · Samir Bellabes

Hi Harald,

Please consider this cleanup patch.

thanks, merged into my tree, will submit with the next bunch of patches

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie