lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190116120647.GE15409@zn.tnic>
Date:   Wed, 16 Jan 2019 13:06:47 +0100
From:   Borislav Petkov <bp@...en8.de>
To:     "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/platform/UV: Replace kmalloc and memset with kzalloc
 and kcalloc

On Tue, Jan 15, 2019 at 11:37:13AM -0600, Gustavo A. R. Silva wrote:
> Replace kmalloc_node and memset with kzalloc_node, and
> kmalloc_array and memset with kcalloc.
> 
> Also, remove unnecessary pointer to void vp.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
> ---
>  arch/x86/platform/uv/tlb_uv.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
> index a4130b84d1ff..ed7e3a21344b 100644
> --- a/arch/x86/platform/uv/tlb_uv.c
> +++ b/arch/x86/platform/uv/tlb_uv.c
> @@ -2010,8 +2010,7 @@ static void make_per_cpu_thp(struct bau_control *smaster)
>  	int cpu;
>  	size_t hpsz = sizeof(struct hub_and_pnode) * num_possible_cpus();
>  
> -	smaster->thp = kmalloc_node(hpsz, GFP_KERNEL, smaster->osnode);
> -	memset(smaster->thp, 0, hpsz);
> +	smaster->thp = kzalloc_node(hpsz, GFP_KERNEL, smaster->osnode);
>  	for_each_present_cpu(cpu) {
>  		smaster->thp[cpu].pnode = uv_cpu_hub_info(cpu)->pnode;
>  		smaster->thp[cpu].uvhub = uv_cpu_hub_info(cpu)->numa_blade_id;
> @@ -2135,15 +2134,12 @@ static int __init summarize_uvhub_sockets(int nuvhubs,
>  static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
>  {
>  	unsigned char *uvhub_mask;
> -	void *vp;
>  	struct uvhub_desc *uvhub_descs;
>  
>  	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
>  		timeout_us = calculate_destination_timeout();
>  
> -	vp = kmalloc_array(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL);
> -	uvhub_descs = (struct uvhub_desc *)vp;
> -	memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
> +	uvhub_descs = kcalloc(nuvhubs, sizeof(*uvhub_descs), GFP_KERNEL);
				       ^^^^^^^^^^^^^^^^^^^^

I'm changing that back to sizeof(struct uvhub_desc) as it is clearer
this way.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ