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: <MWHPR12MB16945AA27004B91E4B5A6C78F7A30@MWHPR12MB1694.namprd12.prod.outlook.com>
Date:   Thu, 3 Nov 2016 16:39:23 +0000
From:   "Deucher, Alexander" <Alexander.Deucher@....com>
To:     'Andrew Shadura' <andrew.shadura@...labora.co.uk>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
        "Koenig, Christian" <Christian.Koenig@....com>,
        David Airlie <airlied@...ux.ie>
CC:     "Zhu, Rex" <Rex.Zhu@....com>, Jammy Zhou <Jammy.Zhou@....com>
Subject: RE: [PATCH] drm/amd/powerplay: return false instead of -EINVAL

> -----Original Message-----
> From: Andrew Shadura [mailto:andrew.shadura@...labora.co.uk]
> Sent: Thursday, November 03, 2016 6:09 AM
> To: linux-kernel@...r.kernel.org; dri-devel@...ts.freedesktop.org; Deucher,
> Alexander; Koenig, Christian; David Airlie
> Cc: Zhu, Rex; Jammy Zhou
> Subject: [PATCH] drm/amd/powerplay: return false instead of -EINVAL
> 
> Returning -EINVAL from a bool-returning function
> phm_check_smc_update_required_for_display_configuration has an
> unexpected
> effect of returning true, which is probably not what was intended.
> Replace -EINVAL by false.
> 
> The only place this function is called from is
> psm_adjust_power_state_dynamic in
> drivers/gpu/drm/amd/powerplay/eventmgr/psm.c:106:
> 
> 	if (!equal ||
> phm_check_smc_update_required_for_display_configuration(hwmgr)) {
> 		phm_apply_state_adjust_rules(hwmgr, requested,
> pcurrent);
> 		phm_set_power_state(hwmgr, &pcurrent->hardware,
> &requested->hardware);
> 		hwmgr->current_ps = requested;
> 	}
> 
> It seems to expect a boolean value here.
> 
> This issue has been found using the following Coccinelle semantic patch
> written by Peter Senna Tschudin:
> <smpl>
> @@
> identifier f;
> constant C;
> typedef bool;
> @@
> bool f (...){
> <+...
> * return -C;
> ...+>
> }
> </smpl>
> 
> Signed-off-by: Andrew Shadura <andrew.shadura@...labora.co.uk>

Reviewed-by: Alex Deucher <alexander.deucher@....com>

I'll pick this up shortly. Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
> b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
> index 789f98a..82038b08 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hardwaremanager.c
> @@ -306,7 +306,7 @@ bool
> phm_check_smc_update_required_for_display_configuration(struct
> pp_hwmgr *hw
>  	PHM_FUNC_CHECK(hwmgr);
> 
>  	if (hwmgr->hwmgr_func-
> >check_smc_update_required_for_display_configuration == NULL)
> -		return -EINVAL;
> +		return false;
> 
>  	return hwmgr->hwmgr_func-
> >check_smc_update_required_for_display_configuration(hwmgr);
>  }
> --
> 2.7.4
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ