[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160425111012.5e06978e@bbrezillon>
Date: Mon, 25 Apr 2016 11:10:12 +0200
From: Boris Brezillon <boris.brezillon@...e-electrons.com>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: David Airlie <airlied@...ux.ie>, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [patch] drm: atmel-hlcdc: fix a NULL check
On Mon, 25 Apr 2016 12:04:54 +0300
Dan Carpenter <dan.carpenter@...cle.com> wrote:
> If kmalloc() returned NULL we would end up dereferencing "state" a
> couple lines later.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
Acked-by: Boris Brezillon <boris.brezillon@...e-electrons.com>
Thanks,
Boris
>
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> index 8df0aaf..867069b 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
> @@ -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;
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
Powered by blists - more mailing lists