Skip to content

Commit

Permalink
amdgpu/dc: Fix potential null dereferences in amdgpu_dm.c
Browse files Browse the repository at this point in the history
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Ernst Sjöstrand <ernstp@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
  • Loading branch information
Ernst Sjöstrand authored and Alex Deucher committed Nov 7, 2017
1 parent b349f76 commit 2a55f09
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,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);

Expand Down Expand Up @@ -3419,6 +3421,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;
Expand Down Expand Up @@ -3449,6 +3453,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 -ENOMEM;
}

aconnector->i2c = i2c;
res = i2c_add_adapter(&i2c->base);

Expand Down

0 comments on commit 2a55f09

Please sign in to comment.