diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-27 08:33:17 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2010-07-01 05:27:35 -0400 |
commit | 485680050166dc8c6ac976346430ab1f453c228b (patch) | |
tree | ee1400398cb1f88dcb975715e16dfa525db9cecf /drivers/dma/timb_dma.c | |
parent | efcc28981745bc6aca88acb2d4d37d87f090a80a (diff) |
drivers/dma: Eliminate a NULL pointer dereference
If td_desc is NULL, just skip both kfrees.
A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
expression E,E1;
identifier f;
statement S1,S2,S3;
@@
if ((E == NULL && ...) || ...)
{
... when != if (...) S1 else S2
when != E = E1
* E->f
... when any
return ...;
}
else S3
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/timb_dma.c')
-rw-r--r-- | drivers/dma/timb_dma.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c index 464fad58dae9..2ec1ed56f204 100644 --- a/drivers/dma/timb_dma.c +++ b/drivers/dma/timb_dma.c | |||
@@ -382,7 +382,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan) | |||
382 | td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL); | 382 | td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL); |
383 | if (!td_desc) { | 383 | if (!td_desc) { |
384 | dev_err(chan2dev(chan), "Failed to alloc descriptor\n"); | 384 | dev_err(chan2dev(chan), "Failed to alloc descriptor\n"); |
385 | goto err; | 385 | goto out; |
386 | } | 386 | } |
387 | 387 | ||
388 | td_desc->desc_list_len = td_chan->desc_elems * TIMB_DMA_DESC_SIZE; | 388 | td_desc->desc_list_len = td_chan->desc_elems * TIMB_DMA_DESC_SIZE; |
@@ -410,7 +410,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan) | |||
410 | err: | 410 | err: |
411 | kfree(td_desc->desc_list); | 411 | kfree(td_desc->desc_list); |
412 | kfree(td_desc); | 412 | kfree(td_desc); |
413 | 413 | out: | |
414 | return NULL; | 414 | return NULL; |
415 | 415 | ||
416 | } | 416 | } |