Skip to content

Commit

Permalink
drm: atmel-hlcdc: fix a NULL check
Browse files Browse the repository at this point in the history
If kmalloc() returned NULL we would end up dereferencing "state" a
couple lines later.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  • Loading branch information
Dan Carpenter authored and Boris Brezillon committed Jun 1, 2016
1 parent c2e4c99 commit 58a2ab3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ atmel_hlcdc_crtc_duplicate_state(struct drm_crtc *crtc)
return NULL;

state = kmalloc(sizeof(*state), GFP_KERNEL);
if (state)
__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
if (!state)
return NULL;
__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);

cur = drm_crtc_state_to_atmel_hlcdc_crtc_state(crtc->state);
state->output_mode = cur->output_mode;
Expand Down

0 comments on commit 58a2ab3

Please sign in to comment.