summaryrefslogtreecommitdiffstats
path: root/drivers/dma-buf
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2018-09-11 15:42:05 +0200
committerGerd Hoffmann <kraxel@redhat.com>2018-09-12 08:21:28 +0200
commita3e722dad03ee75b9e16a8945528ee43fe5ca9ac (patch)
tree0314f0d0912f262a51ef518842e7ff43e8b00d54 /drivers/dma-buf
parent913965c42c57bbe359a7a79a4296731b360a2439 (diff)
downloadlinux-a3e722dad03ee75b9e16a8945528ee43fe5ca9ac.tar.bz2
udmabuf: improve map_udmabuf error handling
Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20180911134216.9760-3-kraxel@redhat.com
Diffstat (limited to 'drivers/dma-buf')
-rw-r--r--drivers/dma-buf/udmabuf.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index 155050c741d9..0d03367c570a 100644
--- a/drivers/dma-buf/udmabuf.c
+++ b/drivers/dma-buf/udmabuf.c
@@ -51,25 +51,24 @@ static struct sg_table *map_udmabuf(struct dma_buf_attachment *at,
{
struct udmabuf *ubuf = at->dmabuf->priv;
struct sg_table *sg;
+ int ret;
sg = kzalloc(sizeof(*sg), GFP_KERNEL);
if (!sg)
- goto err1;
- if (sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->pagecount,
- 0, ubuf->pagecount << PAGE_SHIFT,
- GFP_KERNEL) < 0)
- goto err2;
+ return ERR_PTR(-ENOMEM);
+ ret = sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->pagecount,
+ 0, ubuf->pagecount << PAGE_SHIFT,
+ GFP_KERNEL);
+ if (ret < 0)
+ goto err;
if (!dma_map_sg(at->dev, sg->sgl, sg->nents, direction))
- goto err3;
-
+ goto err;
return sg;
-err3:
+err:
sg_free_table(sg);
-err2:
kfree(sg);
-err1:
- return ERR_PTR(-ENOMEM);
+ return ERR_PTR(ret);
}
static void unmap_udmabuf(struct dma_buf_attachment *at,