diff mbox

[1/2] DRM: Exynos: return NULL if exynos_pages_to_sg fails

Message ID 1340648577-28402-2-git-send-email-subash.ramaswamy@linaro.org
State Accepted
Commit 56fb5380c76d75d30b0e7acdfd36de34b4ee4375
Headers show

Commit Message

Subash Patel June 25, 2012, 6:22 p.m. UTC
From: Subash Patel <subash.rp@samsung.com>

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.

Change-Id: I541ed30491a926ebe72738225041c9f2d88007bc
Signed-off-by: Subash Patel <subash.ramaswamy@linaro.org>
CC: dri-devel@lists.freedesktop.org
CC: linux-samsung-soc@vger.kernel.org
CC: linaro-mm-sig@lists.linaro.org
CC: inki.dae@samsung.com
CC: airlied@redhat.com
CC: olofj@chromium.org
---
 drivers/gpu/drm/exynos/exynos_drm_dmabuf.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

대인기/Tizen Platform Lab(SR)/삼성전자 June 27, 2012, 2:17 a.m. UTC | #1
> -----Original Message-----
> From: Subash Patel [mailto:subashrp@gmail.com]
> Sent: Tuesday, June 26, 2012 3:23 AM
> To: dri-devel@lists.freedesktop.org; linux-samsung-soc@vger.kernel.org;
> linaro-mm-sig@lists.linaro.org
> Cc: olofj@chromium.org; inki.dae@samsung.com; airlied@redhat.com; Subash
> Patel; Subash Patel
> Subject: [PATCH 1/2] DRM: Exynos: return NULL if exynos_pages_to_sg fails
> 
> From: Subash Patel <subash.rp@samsung.com>
> 
> 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.
> 
> Change-Id: I541ed30491a926ebe72738225041c9f2d88007bc
> Signed-off-by: Subash Patel <subash.ramaswamy@linaro.org>
> CC: dri-devel@lists.freedesktop.org
> CC: linux-samsung-soc@vger.kernel.org
> CC: linaro-mm-sig@lists.linaro.org
> CC: inki.dae@samsung.com
> CC: airlied@redhat.com
> CC: olofj@chromium.org
> ---
>  drivers/gpu/drm/exynos/exynos_drm_dmabuf.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> index 97325c1..52cf761 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
> @@ -87,6 +87,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",
> --
> 1.7.9.5

Applied.

Thanks,
Inki Dae
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
index 97325c1..52cf761 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c
@@ -87,6 +87,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",