Skip to content

Commit 58a2ab3

Browse files
Dan CarpenterBoris Brezillon
authored andcommitted
drm: atmel-hlcdc: fix a NULL check
If kmalloc() returned NULL we would end up dereferencing "state" a couple lines later. Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Boris Brezillon <[email protected]>
1 parent c2e4c99 commit 58a2ab3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,9 @@ atmel_hlcdc_crtc_duplicate_state(struct drm_crtc *crtc)
414414
return NULL;
415415

416416
state = kmalloc(sizeof(*state), GFP_KERNEL);
417-
if (state)
418-
__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
417+
if (!state)
418+
return NULL;
419+
__drm_atomic_helper_crtc_duplicate_state(crtc, &state->base);
419420

420421
cur = drm_crtc_state_to_atmel_hlcdc_crtc_state(crtc->state);
421422
state->output_mode = cur->output_mode;

0 commit comments

Comments
 (0)