]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm: atmel-hlcdc: fix a NULL check
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 25 Apr 2016 09:04:54 +0000 (12:04 +0300)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 1 Jun 2016 13:59:36 +0000 (15:59 +0200)
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>
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c

index ac4e0632c2de4f05237ac2d62933bf5a89369775..bd12231ab0cdeeb431b8eba261d1a18459556da5 100644 (file)
@@ -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;