Commit a490d057 authored by Tomi Valkeinen's avatar Tomi Valkeinen Committed by Greg Kroah-Hartman

drm/omap: fix possible NULL ref issue in tiler_reserve_2d

[ Upstream commit 6a0f0c55 ]

tiler_reserve_2d allocates memory but does not check if it got the
memory. Add the check and return ENOMEM on failure.
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180329104038.29154-2-tomi.valkeinen@ti.comReviewed-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9631f32b
...@@ -389,12 +389,16 @@ int tiler_unpin(struct tiler_block *block) ...@@ -389,12 +389,16 @@ int tiler_unpin(struct tiler_block *block)
struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w, struct tiler_block *tiler_reserve_2d(enum tiler_fmt fmt, uint16_t w,
uint16_t h, uint16_t align) uint16_t h, uint16_t align)
{ {
struct tiler_block *block = kzalloc(sizeof(*block), GFP_KERNEL); struct tiler_block *block;
u32 min_align = 128; u32 min_align = 128;
int ret; int ret;
unsigned long flags; unsigned long flags;
u32 slot_bytes; u32 slot_bytes;
block = kzalloc(sizeof(*block), GFP_KERNEL);
if (!block)
return ERR_PTR(-ENOMEM);
BUG_ON(!validfmt(fmt)); BUG_ON(!validfmt(fmt));
/* convert width/height to slots */ /* convert width/height to slots */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment