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: <5a3b3ab7-f5b2-bd66-0587-569411f9af78@daenzer.net>
Date:   Thu, 5 Jul 2018 15:37:14 +0200
From:   Michel Dänzer <michel@...nzer.net>
To:     Kees Cook <keescook@...omium.org>,
        Alex Deucher <alexander.deucher@....com>
Cc:     amd-gfx@...ts.freedesktop.org, Tony Cheng <Tony.Cheng@....com>,
        linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
        Vitaly Prosyak <vitaly.prosyak@....com>,
        Harry Wentland <harry.wentland@....com>
Subject: Re: [PATCH] drm/amd/display: Use 2-factor allocator calls

On 2018-07-04 07:27 PM, Kees Cook wrote:
> As already done treewide, switch from open-coded multiplication to
> 2-factor allocation helper.
> 
> Signed-off-by: Kees Cook <keescook@...omium.org>
> ---
>  drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
> index 98edaefa2b47..ee69c949bfbf 100644
> --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
> +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c
> @@ -1723,8 +1723,8 @@ bool  mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
>  		kvfree(rgb_regamma);
>  	} else if (trans == TRANSFER_FUNCTION_HLG ||
>  		trans == TRANSFER_FUNCTION_HLG12) {
> -		rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
> -				       (MAX_HW_POINTS + _EXTRA_POINTS),
> +		rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
> +				       sizeof(*rgb_regamma),
>  				       GFP_KERNEL);
>  		if (!rgb_regamma)
>  			goto rgb_regamma_alloc_fail;
> @@ -1802,8 +1802,8 @@ bool  mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
>  		kvfree(rgb_degamma);
>  	} else if (trans == TRANSFER_FUNCTION_HLG ||
>  		trans == TRANSFER_FUNCTION_HLG12) {
> -		rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
> -				       (MAX_HW_POINTS + _EXTRA_POINTS),
> +		rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
> +				       sizeof(*rgb_degamma),
>  				       GFP_KERNEL);
>  		if (!rgb_degamma)
>  			goto rgb_degamma_alloc_fail;
> 

Since the values are constant, kvcalloc incurs the overflow checking
overhead for no gain.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ