diff mbox series

drm/amd/display: check dc_link before dereferencing

Message ID 20240227190828.444715-1-mwen@igalia.com (mailing list archive)
State New, archived
Headers show
Series drm/amd/display: check dc_link before dereferencing | expand

Commit Message

Melissa Wen Feb. 27, 2024, 7:08 p.m. UTC
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:6683 amdgpu_dm_connector_funcs_force()
warn: variable dereferenced before check 'dc_link' (see line 6663)

Fixes: 967176179215 ("drm/amd/display: fix null-pointer dereference on edid reading")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Deucher Feb. 29, 2024, 3:46 p.m. UTC | #1
Applied.  Thanks!

On Tue, Feb 27, 2024 at 2:08 PM Melissa Wen <mwen@igalia.com> wrote:
>
> drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:6683 amdgpu_dm_connector_funcs_force()
> warn: variable dereferenced before check 'dc_link' (see line 6663)
>
> Fixes: 967176179215 ("drm/amd/display: fix null-pointer dereference on edid reading")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Signed-off-by: Melissa Wen <mwen@igalia.com>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 32efce81a5a7..46dd06e8fc7e 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6653,7 +6653,7 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
>         struct edid *edid;
>         struct i2c_adapter *ddc;
>
> -       if (dc_link->aux_mode)
> +       if (dc_link && dc_link->aux_mode)
>                 ddc = &aconnector->dm_dp_aux.aux.ddc;
>         else
>                 ddc = &aconnector->i2c->base;
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 32efce81a5a7..46dd06e8fc7e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6653,7 +6653,7 @@  static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
 	struct edid *edid;
 	struct i2c_adapter *ddc;
 
-	if (dc_link->aux_mode)
+	if (dc_link && dc_link->aux_mode)
 		ddc = &aconnector->dm_dp_aux.aux.ddc;
 	else
 		ddc = &aconnector->i2c->base;