Re: [PATCH] video: ARM CLCD: Add missing error check for devm_kzalloc

From: Tomi Valkeinen
Date: Fri Feb 20 2015 - 07:12:33 EST


On 11/02/15 11:36, Kiran Padwal wrote:
> This patch add a missing check on the return value of devm_kzalloc,
> which would cause a NULL pointer dereference in a OOM situation.
>
> Signed-off-by: Kiran Padwal <kiran.padwal@xxxxxxxxxxxxxxx>
> ---
> drivers/video/fbdev/amba-clcd.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
> index 32c0b6b..9362424 100644
> --- a/drivers/video/fbdev/amba-clcd.c
> +++ b/drivers/video/fbdev/amba-clcd.c
> @@ -599,6 +599,9 @@ static int clcdfb_of_get_mode(struct device *dev, struct device_node *endpoint,
>
> len = clcdfb_snprintf_mode(NULL, 0, mode);
> name = devm_kzalloc(dev, len + 1, GFP_KERNEL);
> + if (!name)
> + return -ENOMEM;
> +
> clcdfb_snprintf_mode(name, len + 1, mode);
> mode->name = name;
>
>

Thanks, queued for 3.20.

Tomi


Attachment: signature.asc
Description: OpenPGP digital signature