From: Subash Patel Date: Mon, 25 Jun 2012 18:22:56 +0000 (-0700) Subject: drm/exynos: return NULL if exynos_pages_to_sg fails X-Git-Tag: v3.6-rc1~59^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56fb5380c76d75d30b0e7acdfd36de34b4ee4375;p=platform%2Fkernel%2Flinux-exynos.git drm/exynos: return NULL if exynos_pages_to_sg fails exynos_pages_to_sg() internally calls sg_kmalloc() which can return no pages when the system is under high memory crunch. One such instance is chromeos-install in the chromeos. This patch adds check for the return value of the function in subject to return NULL on failure. Signed-off-by: Subash Patel Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index 2749092..cb29e47 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c @@ -86,6 +86,10 @@ static struct sg_table * npages = buf->size / buf->page_size; sgt = exynos_pages_to_sg(buf->pages, npages, buf->page_size); + if (!sgt) { + DRM_DEBUG_PRIME("exynos_pages_to_sg returned NULL!\n"); + goto err_unlock; + } nents = dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir); DRM_DEBUG_PRIME("npages = %d buffer size = 0x%lx page_size = 0x%lx\n",