linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] dmaengine : xilinx_dma: Fix error handling paths
@ 2022-06-24  6:35 Swati Agarwal
  2022-06-24  6:35 ` [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup Swati Agarwal
  2022-06-24  6:35 ` [PATCH 2/2] dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure Swati Agarwal
  0 siblings, 2 replies; 6+ messages in thread
From: Swati Agarwal @ 2022-06-24  6:35 UTC (permalink / raw)
  To: vkoul, lars, adrianml, libaokun1, marex
  Cc: dmaengine, linux-arm-kernel, linux-kernel, swati.agarwal,
	harini.katakam, radhey.shyam.pandey, michal.simek

Fix Unchecked return value coverity warning.
Fix probe error cleanup.

Swati Agarwal (2):
  dmaengine: xilinx_dma: Fix probe error cleanup
  dmaengine: xilinx_dma: Report error in case of
    dma_set_mask_and_coherent API failure

 drivers/dma/xilinx/xilinx_dma.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup
  2022-06-24  6:35 [PATCH 0/2] dmaengine : xilinx_dma: Fix error handling paths Swati Agarwal
@ 2022-06-24  6:35 ` Swati Agarwal
  2022-07-01 11:50   ` Vinod Koul
  2022-06-24  6:35 ` [PATCH 2/2] dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure Swati Agarwal
  1 sibling, 1 reply; 6+ messages in thread
From: Swati Agarwal @ 2022-06-24  6:35 UTC (permalink / raw)
  To: vkoul, lars, adrianml, libaokun1, marex
  Cc: dmaengine, linux-arm-kernel, linux-kernel, swati.agarwal,
	harini.katakam, radhey.shyam.pandey, michal.simek

When probe fails remove dma channel resources and disable clocks in
accordance with the order of resources allocated .

Add missing cleanup in devm_platform_ioremap_resource(), xlnx,num-fstores
property.

Signed-off-by: Swati Agarwal <swati.agarwal@xilinx.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
 drivers/dma/xilinx/xilinx_dma.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index cd62bbb50e8b..fbf341e8c36f 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -3160,8 +3160,10 @@ static int xilinx_dma_probe(struct platform_device *pdev)
 
 	/* Request and map I/O memory */
 	xdev->regs = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(xdev->regs))
-		return PTR_ERR(xdev->regs);
+	if (IS_ERR(xdev->regs)) {
+		err = PTR_ERR(xdev->regs);
+		goto disable_clks;
+	}
 
 	/* Retrieve the DMA engine properties from the device tree */
 	xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0);
@@ -3190,7 +3192,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
 		if (err < 0) {
 			dev_err(xdev->dev,
 				"missing xlnx,num-fstores property\n");
-			return err;
+			goto disable_clks;
 		}
 
 		err = of_property_read_u32(node, "xlnx,flush-fsync",
@@ -3259,7 +3261,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
 	for_each_child_of_node(node, child) {
 		err = xilinx_dma_child_probe(xdev, child);
 		if (err < 0)
-			goto disable_clks;
+			goto error;
 	}
 
 	if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
@@ -3294,12 +3296,12 @@ static int xilinx_dma_probe(struct platform_device *pdev)
 
 	return 0;
 
-disable_clks:
-	xdma_disable_allclks(xdev);
 error:
 	for (i = 0; i < xdev->dma_config->max_channels; i++)
 		if (xdev->chan[i])
 			xilinx_dma_chan_remove(xdev->chan[i]);
+disable_clks:
+	xdma_disable_allclks(xdev);
 
 	return err;
 }
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure
  2022-06-24  6:35 [PATCH 0/2] dmaengine : xilinx_dma: Fix error handling paths Swati Agarwal
  2022-06-24  6:35 ` [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup Swati Agarwal
@ 2022-06-24  6:35 ` Swati Agarwal
  1 sibling, 0 replies; 6+ messages in thread
From: Swati Agarwal @ 2022-06-24  6:35 UTC (permalink / raw)
  To: vkoul, lars, adrianml, libaokun1, marex
  Cc: dmaengine, linux-arm-kernel, linux-kernel, swati.agarwal,
	harini.katakam, radhey.shyam.pandey, michal.simek

The driver does not handle the failure case while calling
dma_set_mask_and_coherent API.

In case of failure, capture the return value of API and then report an
error.

Addresses-coverity: Unchecked return value (CHECKED_RETURN)

Signed-off-by: Swati Agarwal <swati.agarwal@xilinx.com>
Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
---
 drivers/dma/xilinx/xilinx_dma.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index fbf341e8c36f..194513eca7a2 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -3212,7 +3212,11 @@ static int xilinx_dma_probe(struct platform_device *pdev)
 		xdev->ext_addr = false;
 
 	/* Set the dma mask bits */
-	dma_set_mask_and_coherent(xdev->dev, DMA_BIT_MASK(addr_width));
+	err = dma_set_mask_and_coherent(xdev->dev, DMA_BIT_MASK(addr_width));
+	if (err < 0) {
+		dev_err(xdev->dev, "DMA mask error %d\n", err);
+		goto disable_clks;
+	}
 
 	/* Initialize the DMA engine */
 	xdev->common.dev = &pdev->dev;
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup
  2022-06-24  6:35 ` [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup Swati Agarwal
@ 2022-07-01 11:50   ` Vinod Koul
  2022-07-12  7:36     ` Agarwal, Swati
  0 siblings, 1 reply; 6+ messages in thread
From: Vinod Koul @ 2022-07-01 11:50 UTC (permalink / raw)
  To: Swati Agarwal
  Cc: lars, adrianml, libaokun1, marex, dmaengine, linux-arm-kernel,
	linux-kernel, harini.katakam, radhey.shyam.pandey, michal.simek

On 24-06-22, 12:05, Swati Agarwal wrote:
> When probe fails remove dma channel resources and disable clocks in
> accordance with the order of resources allocated .

Ok this looks fine and the changes below..
> 
> Add missing cleanup in devm_platform_ioremap_resource(), xlnx,num-fstores
> property.

Where is this part?

> 
> Signed-off-by: Swati Agarwal <swati.agarwal@xilinx.com>
> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
> ---
>  drivers/dma/xilinx/xilinx_dma.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
> index cd62bbb50e8b..fbf341e8c36f 100644
> --- a/drivers/dma/xilinx/xilinx_dma.c
> +++ b/drivers/dma/xilinx/xilinx_dma.c
> @@ -3160,8 +3160,10 @@ static int xilinx_dma_probe(struct platform_device *pdev)
>  
>  	/* Request and map I/O memory */
>  	xdev->regs = devm_platform_ioremap_resource(pdev, 0);
> -	if (IS_ERR(xdev->regs))
> -		return PTR_ERR(xdev->regs);
> +	if (IS_ERR(xdev->regs)) {
> +		err = PTR_ERR(xdev->regs);
> +		goto disable_clks;
> +	}
>  
>  	/* Retrieve the DMA engine properties from the device tree */
>  	xdev->max_buffer_len = GENMASK(XILINX_DMA_MAX_TRANS_LEN_MAX - 1, 0);
> @@ -3190,7 +3192,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
>  		if (err < 0) {
>  			dev_err(xdev->dev,
>  				"missing xlnx,num-fstores property\n");
> -			return err;
> +			goto disable_clks;
>  		}
>  
>  		err = of_property_read_u32(node, "xlnx,flush-fsync",
> @@ -3259,7 +3261,7 @@ static int xilinx_dma_probe(struct platform_device *pdev)
>  	for_each_child_of_node(node, child) {
>  		err = xilinx_dma_child_probe(xdev, child);
>  		if (err < 0)
> -			goto disable_clks;
> +			goto error;
>  	}
>  
>  	if (xdev->dma_config->dmatype == XDMA_TYPE_VDMA) {
> @@ -3294,12 +3296,12 @@ static int xilinx_dma_probe(struct platform_device *pdev)
>  
>  	return 0;
>  
> -disable_clks:
> -	xdma_disable_allclks(xdev);
>  error:
>  	for (i = 0; i < xdev->dma_config->max_channels; i++)
>  		if (xdev->chan[i])
>  			xilinx_dma_chan_remove(xdev->chan[i]);
> +disable_clks:
> +	xdma_disable_allclks(xdev);
>  
>  	return err;
>  }
> -- 
> 2.17.1

-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup
  2022-07-01 11:50   ` Vinod Koul
@ 2022-07-12  7:36     ` Agarwal, Swati
  2022-07-21 13:36       ` Vinod Koul
  0 siblings, 1 reply; 6+ messages in thread
From: Agarwal, Swati @ 2022-07-12  7:36 UTC (permalink / raw)
  To: Vinod Koul, Swati Agarwal
  Cc: lars, adrianml, libaokun1, marex, dmaengine, linux-arm-kernel,
	linux-kernel, harini.katakam, radhey.shyam.pandey, michal.simek,
	Agarwal, Swati, Katakam, Harini, Pandey, Radhey Shyam, Simek,
	Michal

Hi Vinod,

> -----Original Message-----
> From: Vinod Koul <vkoul@kernel.org>
> Sent: Friday, July 1, 2022 5:21 PM
> To: Swati Agarwal <swati.agarwal@xilinx.com>
> Cc: lars@metafoo.de; adrianml@alumnos.upm.es; libaokun1@huawei.com;
> marex@denx.de; dmaengine@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> harini.katakam@xilinx.com; radhey.shyam.pandey@xilinx.com;
> michal.simek@xilinx.com
> Subject: Re: [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup
> 
> CAUTION: This message has originated from an External Source. Please use
> proper judgment and caution when opening attachments, clicking links, or
> responding to this email.
> 
> 
> On 24-06-22, 12:05, Swati Agarwal wrote:
> > When probe fails remove dma channel resources and disable clocks in
> > accordance with the order of resources allocated .
> 
> Ok this looks fine and the changes below..

Thanks for the review!!
Sorry for the delayed reply. I missed this mail due to some mailer issues.

> >
> > Add missing cleanup in devm_platform_ioremap_resource(),
> > xlnx,num-fstores property.
> 
> Where is this part?

The statement is an elaboration of the previous one. The relevant code is below.

<snip>
> >       /* Request and map I/O memory */
> >       xdev->regs = devm_platform_ioremap_resource(pdev, 0);
> > -     if (IS_ERR(xdev->regs))
> > -             return PTR_ERR(xdev->regs);
> > +     if (IS_ERR(xdev->regs)) {
> > +             err = PTR_ERR(xdev->regs);
> > +             goto disable_clks;
> > +     }

This  

<snip>
> >               if (err < 0) {
> >                       dev_err(xdev->dev,
> >                               "missing xlnx,num-fstores property\n");
> > -                     return err;
> > +                     goto disable_clks;
> >               }

And this

Regards,
Swati Agarwal


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup
  2022-07-12  7:36     ` Agarwal, Swati
@ 2022-07-21 13:36       ` Vinod Koul
  0 siblings, 0 replies; 6+ messages in thread
From: Vinod Koul @ 2022-07-21 13:36 UTC (permalink / raw)
  To: Agarwal, Swati
  Cc: Swati Agarwal, lars, adrianml, libaokun1, marex, dmaengine,
	linux-arm-kernel, linux-kernel, harini.katakam,
	radhey.shyam.pandey, michal.simek, Katakam, Harini, Pandey,
	Radhey Shyam, Simek, Michal

On 12-07-22, 07:36, Agarwal, Swati wrote:
> Hi Vinod,
> 
> > -----Original Message-----
> > From: Vinod Koul <vkoul@kernel.org>
> > Sent: Friday, July 1, 2022 5:21 PM
> > To: Swati Agarwal <swati.agarwal@xilinx.com>
> > Cc: lars@metafoo.de; adrianml@alumnos.upm.es; libaokun1@huawei.com;
> > marex@denx.de; dmaengine@vger.kernel.org; linux-arm-
> > kernel@lists.infradead.org; linux-kernel@vger.kernel.org;
> > harini.katakam@xilinx.com; radhey.shyam.pandey@xilinx.com;
> > michal.simek@xilinx.com
> > Subject: Re: [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup
> > 
> > CAUTION: This message has originated from an External Source. Please use
> > proper judgment and caution when opening attachments, clicking links, or
> > responding to this email.
> > 
> > 
> > On 24-06-22, 12:05, Swati Agarwal wrote:
> > > When probe fails remove dma channel resources and disable clocks in
> > > accordance with the order of resources allocated .
> > 
> > Ok this looks fine and the changes below..
> 
> Thanks for the review!!
> Sorry for the delayed reply. I missed this mail due to some mailer issues.
> 
> > >
> > > Add missing cleanup in devm_platform_ioremap_resource(),
> > > xlnx,num-fstores property.
> > 
> > Where is this part?
> 
> The statement is an elaboration of the previous one. The relevant code is below.

Okay, a patch should do only One thing, pls consider splitting it up...

> 
> <snip>
> > >       /* Request and map I/O memory */
> > >       xdev->regs = devm_platform_ioremap_resource(pdev, 0);
> > > -     if (IS_ERR(xdev->regs))
> > > -             return PTR_ERR(xdev->regs);
> > > +     if (IS_ERR(xdev->regs)) {
> > > +             err = PTR_ERR(xdev->regs);
> > > +             goto disable_clks;
> > > +     }
> 
> This  
> 
> <snip>
> > >               if (err < 0) {
> > >                       dev_err(xdev->dev,
> > >                               "missing xlnx,num-fstores property\n");
> > > -                     return err;
> > > +                     goto disable_clks;
> > >               }
> 
> And this
> 
> Regards,
> Swati Agarwal

-- 
~Vinod

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-07-21 13:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24  6:35 [PATCH 0/2] dmaengine : xilinx_dma: Fix error handling paths Swati Agarwal
2022-06-24  6:35 ` [PATCH 1/2] dmaengine: xilinx_dma: Fix probe error cleanup Swati Agarwal
2022-07-01 11:50   ` Vinod Koul
2022-07-12  7:36     ` Agarwal, Swati
2022-07-21 13:36       ` Vinod Koul
2022-06-24  6:35 ` [PATCH 2/2] dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure Swati Agarwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).