linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] skd: fix unchecked return values
@ 2018-10-19 18:44 Gustavo A. R. Silva
  2018-10-22  9:14 ` Christoph Hellwig
  2018-10-22  9:16 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-10-19 18:44 UTC (permalink / raw)
  To: Bart Van Assche, Jens Axboe, Christoph Hellwig
  Cc: linux-block, linux-kernel, Gustavo A. R. Silva

Check return values of dma_set_mask_and_coherent().

Otherwise, if dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
fails, the following piece of code will be executed even when the call
to dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); returns 0:

dev_err(&pdev->dev, "DMA mask error %d\n", rc);
goto err_out_regions;

Addresses-Coverity-ID: 1474553 ("Unchecked return value")
Fixes: 138126214868 ("skd: switch to the generic DMA API")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/block/skd_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 7c5fc69..2459dcc 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -3175,7 +3175,7 @@ static int skd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto err_out;
 	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
 	if (rc)
-		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 	if (rc) {
 		dev_err(&pdev->dev, "DMA mask error %d\n", rc);
 		goto err_out_regions;
@@ -3364,7 +3364,7 @@ static int skd_pci_resume(struct pci_dev *pdev)
 		goto err_out;
 	rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
 	if (rc)
-		dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
+		rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 	if (rc) {
 		dev_err(&pdev->dev, "DMA mask error %d\n", rc);
 		goto err_out_regions;
-- 
2.7.4


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

* Re: [PATCH] skd: fix unchecked return values
  2018-10-19 18:44 [PATCH] skd: fix unchecked return values Gustavo A. R. Silva
@ 2018-10-22  9:14 ` Christoph Hellwig
  2018-10-22  9:16 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-10-22  9:14 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Bart Van Assche, Jens Axboe, Christoph Hellwig, linux-block,
	linux-kernel

On Fri, Oct 19, 2018 at 08:44:17PM +0200, Gustavo A. R. Silva wrote:
> Check return values of dma_set_mask_and_coherent().
> 
> Otherwise, if dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> fails, the following piece of code will be executed even when the call
> to dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); returns 0:
> 
> dev_err(&pdev->dev, "DMA mask error %d\n", rc);
> goto err_out_regions;
> 
> Addresses-Coverity-ID: 1474553 ("Unchecked return value")
> Fixes: 138126214868 ("skd: switch to the generic DMA API")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Thanks, looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH] skd: fix unchecked return values
  2018-10-19 18:44 [PATCH] skd: fix unchecked return values Gustavo A. R. Silva
  2018-10-22  9:14 ` Christoph Hellwig
@ 2018-10-22  9:16 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2018-10-22  9:16 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Bart Van Assche, Christoph Hellwig
  Cc: linux-block, linux-kernel

On 10/19/18 12:44 PM, Gustavo A. R. Silva wrote:
> Check return values of dma_set_mask_and_coherent().
> 
> Otherwise, if dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
> fails, the following piece of code will be executed even when the call
> to dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); returns 0:
> 
> dev_err(&pdev->dev, "DMA mask error %d\n", rc);
> goto err_out_regions;

Applied, thanks.

-- 
Jens Axboe


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

end of thread, other threads:[~2018-10-22  9:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-19 18:44 [PATCH] skd: fix unchecked return values Gustavo A. R. Silva
2018-10-22  9:14 ` Christoph Hellwig
2018-10-22  9:16 ` Jens Axboe

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).