[PATCH 2/3] amdgpu/dc: Fix potential null dereference in amdgpu_dm.c
Deucher, Alexander
Alexander.Deucher at amd.com
Tue Nov 7 14:15:54 UTC 2017
> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces at lists.freedesktop.org] On Behalf
> Of Ernst Sjöstrand
> Sent: Monday, November 06, 2017 6:55 PM
> To: amd-gfx at lists.freedesktop.org
> Cc: Ernst Sjöstrand
> Subject: [PATCH 2/3] amdgpu/dc: Fix potential null dereference in
> amdgpu_dm.c
>
> Signed-off-by: Ernst Sjöstrand <ernstp at gmail.com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> 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 e6bfa9f30900..2301589e4cc3 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -2413,6 +2413,8 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc)
> return NULL;
>
> state = kzalloc(sizeof(*state), GFP_KERNEL);
> + if (!state)
> + return NULL;
>
> __drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
>
> @@ -3443,6 +3445,8 @@ create_i2c(struct ddc_service *ddc_service,
> struct amdgpu_i2c_adapter *i2c;
>
> i2c = kzalloc(sizeof(struct amdgpu_i2c_adapter), GFP_KERNEL);
> + if (!i2c)
> + return NULL;
> i2c->base.owner = THIS_MODULE;
> i2c->base.class = I2C_CLASS_DDC;
> i2c->base.dev.parent = &adev->pdev->dev;
> @@ -3473,6 +3477,11 @@ static int amdgpu_dm_connector_init(struct
> amdgpu_display_manager *dm,
> DRM_DEBUG_DRIVER("%s()\n", __func__);
>
> i2c = create_i2c(link->ddc, link->link_index, &res);
> + if (!i2c) {
> + DRM_ERROR("Failed to create i2c adapter data\n");
> + return -1;
Please return -ENOMEM here.
Alex
> + }
> +
> aconnector->i2c = i2c;
> res = i2c_add_adapter(&i2c->base);
>
> --
> 2.14.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
More information about the amd-gfx
mailing list