lkml.org 
[lkml]   [2022]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 5.10 262/563] uio: uio_dmem_genirq: Catch the Exception
Hi!

> From: Jiasheng Jiang <jiasheng@iscas.ac.cn>
>
> [ Upstream commit eec91694f927d1026974444eb6a3adccd4f1cbc2 ]
>
> The return value of dma_set_coherent_mask() is not always 0.
> To catch the exception in case that dma is not support the mask.
>
> Fixes: 0a0c3b5a24bd ("Add new uio device for dynamic memory allocation")


> +++ b/drivers/uio/uio_dmem_genirq.c
> @@ -183,7 +183,11 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
> goto bad0;
> }
>
> - dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> + ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
> + if (ret) {
> + dev_err(&pdev->dev, "DMA enable failed\n");
> + return ret;
> + }

Handing errors is good, but you may not directly return here as it
would leak the resources. Something like this?

Signed-off-by: Pavel Machek <pavel@denx.de>

Best regards,
Pavel

diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index bf39a424ea77..7b80d0c02735 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -186,7 +186,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(&pdev->dev, "DMA enable failed\n");
- return ret;
+ goto bad0;
}

priv->uioinfo = uioinfo;


--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-01-25 11:50    [W:1.728 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site