]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/prime: fix to check return of dma_map_sg in prime helper
authorYoungJun Cho <yj44.cho@samsung.com>
Mon, 24 Jun 2013 06:34:21 +0000 (15:34 +0900)
committerDave Airlie <airlied@redhat.com>
Fri, 28 Jun 2013 02:45:11 +0000 (12:45 +1000)
The dma_map_sg(), in map_dma_buf callback operation of prime helper,
can return 0 when it fails to map, so it needs to release related
resources.

Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_prime.c

index e57c675db840a61449f596e5c69177844545a4f5..0daf2122a91dc386f58498ecaedff7869982a976 100644 (file)
@@ -97,8 +97,13 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach,
 
        sgt = obj->dev->driver->gem_prime_get_sg_table(obj);
 
-       if (!IS_ERR_OR_NULL(sgt))
-               dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir);
+       if (!IS_ERR_OR_NULL(sgt)) {
+               if (!dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir)) {
+                       sg_free_table(sgt);
+                       kfree(sgt);
+                       sgt = ERR_PTR(-ENOMEM);
+               }
+       }
 
        mutex_unlock(&obj->dev->struct_mutex);
        return sgt;