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>] [day] [month] [year] [list]
Message-ID: <edf173d9-8b59-ecab-99d0-1063b51574a9@amd.com>
Date:   Tue, 11 Apr 2023 17:04:04 +0200
From:   Christian König <christian.koenig@....com>
To:     Markus Elfring <Markus.Elfring@....de>,
        kernel-janitors@...r.kernel.org, amd-gfx@...ts.freedesktop.org,
        dri-devel@...ts.freedesktop.org, Alan Liu <HaoPing.Liu@....com>,
        Alex Deucher <alexander.deucher@....com>,
        Alex Hung <alex.hung@....com>,
        Alexey Kodanev <aleksei.kodanev@...l-sw.com>,
        Aurabindo Pillai <aurabindo.pillai@....com>,
        Bhanuprakash Modem <bhanuprakash.modem@...el.com>,
        Candice Li <candice.li@....com>,
        Charlene Liu <charlene.liu@....com>,
        Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...il.com>,
        David Tadokoro <davidbtadokoro@....br>,
        Eryk Brol <eryk.brol@....com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Hamza Mahfooz <hamza.mahfooz@....com>,
        Harry Wentland <harry.wentland@....com>,
        Hawking Zhang <Hawking.Zhang@....com>,
        hersen wu <hersenxs.wu@....com>,
        Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>,
        Jun Lei <jun.lei@....com>, Leo Li <sunpeng.li@....com>,
        Mikita Lipski <mikita.lipski@....com>,
        Rodrigo Siqueira <Rodrigo.Siqueira@....com>,
        Stanley Yang <Stanley.Yang@....com>,
        Tao Zhou <tao.zhou1@....com>, Tom Rix <trix@...hat.com>,
        Victor Zhao <Victor.Zhao@....com>,
        Wayne Lin <Wayne.Lin@....com>,
        Wenjing Liu <wenjing.liu@....com>,
        Xinhui Pan <Xinhui.Pan@....com>,
        YiPeng Chai <YiPeng.Chai@....com>, Zhan Liu <zhan.liu@....com>
Cc:     cocci@...ia.fr, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/5] drm/amd/display: Move three variable assignments
 behind condition checks in trigger_hotplug()

Am 11.04.23 um 15:43 schrieb Markus Elfring:
> Date: Tue, 11 Apr 2023 11:39:02 +0200
>
> The address of a data structure member was determined before
> a corresponding null pointer check in the implementation of
> the function “trigger_hotplug”.
>
> Thus avoid the risk for undefined behaviour by moving the assignment
> for three local variables behind some condition checks.

It might be that the NULL check doesn't make sense in the first place, 
but since I'm not an expert for this code I can't fully judge.

On the other hand the patches clearly look like nice cleanups to me, so 
feel free to add an Acked-by: Christian König <christian.koenig@....com> 
to the series.

Thanks,
Christian.

>
> This issue was detected by using the Coccinelle software.
>
> Fixes: 6f77b2ac628073f647041a92b36c824ae3aef16e ("drm/amd/display: Add connector HPD trigger debugfs entry")
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c  | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index 827fcb4fb3b3..b3cfd7dfbb28 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -1205,10 +1205,10 @@ static ssize_t trigger_hotplug(struct file *f, const char __user *buf,
>   							size_t size, loff_t *pos)
>   {
>   	struct amdgpu_dm_connector *aconnector = file_inode(f)->i_private;
> -	struct drm_connector *connector = &aconnector->base;
> +	struct drm_connector *connector;
>   	struct dc_link *link = NULL;
> -	struct drm_device *dev = connector->dev;
> -	struct amdgpu_device *adev = drm_to_adev(dev);
> +	struct drm_device *dev;
> +	struct amdgpu_device *adev;
>   	enum dc_connection_type new_connection_type = dc_connection_none;
>   	char *wr_buf = NULL;
>   	uint32_t wr_buf_size = 42;
> @@ -1253,12 +1253,16 @@ static ssize_t trigger_hotplug(struct file *f, const char __user *buf,
>   		return -EINVAL;
>   	}
>
> +	connector = &aconnector->base;
> +	dev = connector->dev;
> +
>   	if (param[0] == 1) {
>
>   		if (!dc_link_detect_connection_type(aconnector->dc_link, &new_connection_type) &&
>   			new_connection_type != dc_connection_none)
>   			goto unlock;
>
> +		adev = drm_to_adev(dev);
>   		mutex_lock(&adev->dm.dc_lock);
>   		ret = dc_link_detect(aconnector->dc_link, DETECT_REASON_HPD);
>   		mutex_unlock(&adev->dm.dc_lock);
> --
> 2.40.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ