diff mbox series

[02/10] udmabuf: improve map_udmabuf error handling

Message ID 20180911065921.23818-3-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series [01/10] udmabuf: sort headers, drop uapi/ path prefix | expand

Commit Message

Gerd Hoffmann Sept. 11, 2018, 6:59 a.m. UTC
Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/dma-buf/udmabuf.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Comments

Laurent Pinchart Sept. 11, 2018, 9:37 a.m. UTC | #1
Hi Gerd,

Thank you for the patch.

On Tuesday, 11 September 2018 09:59:13 EEST Gerd Hoffmann wrote:

A commit message would be nice, for all patches in this series.

> Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Reviewed-by: Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/dma-buf/udmabuf.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
> index e63d301bcb..19bd918209 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,
diff mbox series

Patch

diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
index e63d301bcb..19bd918209 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,