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: <614a4844-fa5d-8b8e-0628-894394f31608@amd.com>
Date:   Tue, 5 Apr 2022 19:38:27 +0200
From:   Christian König <christian.koenig@....com>
To:     Grigory Vasilyev <h0tc0d3@...il.com>,
        Rodrigo Siqueira <Rodrigo.Siqueira@....com>,
        Melissa Wen <mwen@...lia.com>
Cc:     Alex Deucher <alexander.deucher@....com>,
        "Pan, Xinhui" <Xinhui.Pan@....com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        Jani Nikula <jani.nikula@...el.com>,
        Jiawei Gu <Jiawei.Gu@....com>,
        Lucas De Marchi <lucas.demarchi@...el.com>,
        amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/amdgpu: Senseless code and unnecessary memset

Am 05.04.22 um 19:36 schrieb Grigory Vasilyev:
> Using memset on local arrays before exiting the function is pointless.
> Compilator will remove this code. Also for local arrays is preferable to
> use {0} instead of memset. Mistakes are often made when working with
> memset.

Well actually memset is preferred when working with structures which are 
given to the hardware parser because {0} won't initialize paddings.

So please don't use {0} in any of the atom bios code.

Regards,
Christian.

>
> Signed-off-by: Grigory Vasilyev <h0tc0d3@...il.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/atom.c | 8 +-------
>   1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c
> index be9d61bcb8ae..537e48fbbe6b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/atom.c
> +++ b/drivers/gpu/drm/amd/amdgpu/atom.c
> @@ -1538,11 +1538,9 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
>   int amdgpu_atom_asic_init(struct atom_context *ctx)
>   {
>   	int hwi = CU16(ctx->data_table + ATOM_DATA_FWI_PTR);
> -	uint32_t ps[16];
> +	uint32_t ps[16] = {0};
>   	int ret;
>   
> -	memset(ps, 0, 64);
> -
>   	ps[0] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFSCLK_PTR));
>   	ps[1] = cpu_to_le32(CU32(hwi + ATOM_FWI_DEFMCLK_PTR));
>   	if (!ps[0] || !ps[1])
> @@ -1551,10 +1549,6 @@ int amdgpu_atom_asic_init(struct atom_context *ctx)
>   	if (!CU16(ctx->cmd_table + 4 + 2 * ATOM_CMD_INIT))
>   		return 1;
>   	ret = amdgpu_atom_execute_table(ctx, ATOM_CMD_INIT, ps);
> -	if (ret)
> -		return ret;
> -
> -	memset(ps, 0, 64);
>   
>   	return ret;
>   }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ