linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/netfilter/x_tables.c: Use kvalloc to make your code better
@ 2021-12-10  3:12 lizhe
  2021-12-10  8:12 ` Florian Westphal
  0 siblings, 1 reply; 2+ messages in thread
From: lizhe @ 2021-12-10  3:12 UTC (permalink / raw)
  To: pablo, kadlec, fw, davem, kuba, sensor1010
  Cc: netfilter-devel, coreteam, netdev, linux-kernel

Use kvzalloc () instead of kvmalloc () and memset

Signed-off-by: lizhe <sensor1010@163.com>
---
 net/netfilter/x_tables.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 25524e393349..8d6ffed7d526 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -1189,11 +1189,10 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
 	if (sz < sizeof(*info) || sz >= XT_MAX_TABLE_SIZE)
 		return NULL;
 
-	info = kvmalloc(sz, GFP_KERNEL_ACCOUNT);
+	info = kvzalloc(sz, GFP_KERNEL_ACCOUNT);
 	if (!info)
 		return NULL;
 
-	memset(info, 0, sizeof(*info));
 	info->size = size;
 	return info;
 }
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net/netfilter/x_tables.c: Use kvalloc to make your code better
  2021-12-10  3:12 [PATCH] net/netfilter/x_tables.c: Use kvalloc to make your code better lizhe
@ 2021-12-10  8:12 ` Florian Westphal
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2021-12-10  8:12 UTC (permalink / raw)
  To: lizhe
  Cc: pablo, kadlec, fw, davem, kuba, netfilter-devel, coreteam,
	netdev, linux-kernel

lizhe <sensor1010@163.com> wrote:
> Use kvzalloc () instead of kvmalloc () and memset
> 
> Signed-off-by: lizhe <sensor1010@163.com>
> ---
>  net/netfilter/x_tables.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> index 25524e393349..8d6ffed7d526 100644
> --- a/net/netfilter/x_tables.c
> +++ b/net/netfilter/x_tables.c
> @@ -1189,11 +1189,10 @@ struct xt_table_info *xt_alloc_table_info(unsigned int size)
>  	if (sz < sizeof(*info) || sz >= XT_MAX_TABLE_SIZE)
>  		return NULL;
>  
> -	info = kvmalloc(sz, GFP_KERNEL_ACCOUNT);
> +	info = kvzalloc(sz, GFP_KERNEL_ACCOUNT);
>  	if (!info)
>  		return NULL;
>  
> -	memset(info, 0, sizeof(*info));

sz != sizeof(*info)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-10  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10  3:12 [PATCH] net/netfilter/x_tables.c: Use kvalloc to make your code better lizhe
2021-12-10  8:12 ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).