drm: atmel-hlcdc: fix a NULL check
Subsystems (5)
PATCH 1/1 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]>
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +3 -2
@@ -415,8 +415,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;
Quoted 4 lines · On Mon, 25 Apr 2016 12:04:54 +0300 Dan Carpenter <[email protected]>…
If
kmalloc()returned NULL we would end up dereferencing "state" a couple lines later.Signed-off-by Dan Carpenter <[email protected]>
Acked-by Boris Brezillon <[email protected]>
Thanks,
Boris
Quoted 17 lines
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +3
-2@@ -415,8 +415,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;
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
Quoted 4 lines · Dan Carpenter
If
kmalloc()returned NULL we would end up dereferencing "state" a couple lines later.Signed-off-by Dan Carpenter <[email protected]>
Reviewed-by Eric Engestrom <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Daniel,
Quoted 2 lines · On Mon, 25 Apr 2016 12:04:54 +0300 Dan Carpenter <[email protected]>…
If
kmalloc()returned NULL we would end up dereferencing "state" a couple lines later.
Can you take this patch in drm-misc, or should I send a PR?
Regards,
Boris
Quoted 19 lines
Signed-off-by Dan Carpenter <[email protected]>drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c +3
-2@@ -415,8 +415,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;
Signature · 3 lines
Boris Brezillon, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com