Skip to content

Commit 02ffc5f

Browse files
Julia Lawallbroonie
authored andcommitted
ASoC: davinci-mcasp.c: Return error code in failure
In this code, 0 is returned on failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @A@ identifier alloc; identifier ret; constant C; expression x; @@ x = alloc(...); if (x == NULL) { <+... \(ret = -C; \| return -C; \) ...+> } @@ identifier f, a.alloc; expression ret; expression x,e1,e2,e3; @@ ret = 0 ... when != ret = e1 *x = alloc(...) ... when != ret = e2 if (x == NULL) { ... when != ret = e3 return ret; } // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent f676550 commit 02ffc5f

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎sound/soc/davinci/davinci-mcasp.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
898898
res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
899899
if (!res) {
900900
dev_err(&pdev->dev, "no DMA resource\n");
901+
ret = -ENODEV;
901902
goto err_release_region;
902903
}
903904

@@ -912,6 +913,7 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
912913
res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
913914
if (!res) {
914915
dev_err(&pdev->dev, "no DMA resource\n");
916+
ret = -ENODEV;
915917
goto err_release_region;
916918
}
917919

0 commit comments

Comments
 (0)