[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.1008111210490.8669@ask.diku.dk>
Date: Wed, 11 Aug 2010 12:11:07 +0200 (CEST)
From: Julia Lawall <julia@...u.dk>
To: Linus Walleij <linus.walleij@...ricsson.com>,
Dan Williams <dan.j.williams@...el.com>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH 2/5] drivers/dma: Return -ENOMEM on memory allocation failure
From: Julia Lawall <julia@...u.dk>
In this code, 0 is returned on memory allocation 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>
@@
expression ret;
expression x,e1,e2,e3;
@@
ret = 0
... when != ret = e1
*x = \(kmalloc\|kcalloc\|kzalloc\)(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <julia@...u.dk>
---
drivers/dma/coh901318.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/coh901318.c b/drivers/dma/coh901318.c
index 557e227..6dd9488 100644
--- a/drivers/dma/coh901318.c
+++ b/drivers/dma/coh901318.c
@@ -1475,8 +1475,10 @@ static int __init coh901318_probe(struct platform_device *pdev)
pdata->max_channels *
sizeof(struct coh901318_chan),
GFP_KERNEL);
- if (!base)
+ if (!base) {
+ err = -ENOMEM;
goto err_alloc_coh_dma_channels;
+ }
base->chans = ((void *)base) + ALIGN(sizeof(struct coh901318_base), 4);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists