* [PATCH 2/5] drivers/dma: Return -ENOMEM on memory allocation failure
@ 2010-08-11 10:11 Julia Lawall
2010-08-11 11:22 ` Linus WALLEIJ
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-08-11 10:11 UTC (permalink / raw)
To: Linus Walleij, Dan Williams, linux-arm-kernel, linux-kernel,
kernel-janitors
From: Julia Lawall <julia@diku.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@diku.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);
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH 2/5] drivers/dma: Return -ENOMEM on memory allocation failure
2010-08-11 10:11 [PATCH 2/5] drivers/dma: Return -ENOMEM on memory allocation failure Julia Lawall
@ 2010-08-11 11:22 ` Linus WALLEIJ
0 siblings, 0 replies; 2+ messages in thread
From: Linus WALLEIJ @ 2010-08-11 11:22 UTC (permalink / raw)
To: Julia Lawall, Dan Williams, linux-arm-kernel, linux-kernel,
kernel-janitors
> From: Julia Lawall <julia@diku.dk>
>
> In this code, 0 is returned on memory allocation failure, even though
> other failures return -ENOMEM or other similar values.
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Thanks for fixing this Julia!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-11 11:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-11 10:11 [PATCH 2/5] drivers/dma: Return -ENOMEM on memory allocation failure Julia Lawall
2010-08-11 11:22 ` Linus WALLEIJ
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®