diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2012-08-14 01:49:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-08-14 19:59:43 -0400 |
commit | f37c54b6a6c56489221d42ff27305e4f8098e34b (patch) | |
tree | 5c0d7a6e98f10860dbfeffddf1bd5bd5e245b7e6 | |
parent | aadf31de16a7b2878af00a02e6557df84efa784b (diff) |
drivers/net/ethernet/ti/davinci_cpdma.c: Remove potential NULL dereference
If the NULL test is necessary, the initialization involving a dereference of
the tested value should be moved after the NULL test.
The sematic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
type T;
expression E;
identifier i,fld;
statement S;
@@
- T i = E->fld;
+ T i;
... when != E
when != i
if (E == NULL) S
+ i = E->fld;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/ti/davinci_cpdma.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 3b5c4571b55e..d15c888e9df8 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c | |||
@@ -538,11 +538,12 @@ EXPORT_SYMBOL_GPL(cpdma_chan_create); | |||
538 | 538 | ||
539 | int cpdma_chan_destroy(struct cpdma_chan *chan) | 539 | int cpdma_chan_destroy(struct cpdma_chan *chan) |
540 | { | 540 | { |
541 | struct cpdma_ctlr *ctlr = chan->ctlr; | 541 | struct cpdma_ctlr *ctlr; |
542 | unsigned long flags; | 542 | unsigned long flags; |
543 | 543 | ||
544 | if (!chan) | 544 | if (!chan) |
545 | return -EINVAL; | 545 | return -EINVAL; |
546 | ctlr = chan->ctlr; | ||
546 | 547 | ||
547 | spin_lock_irqsave(&ctlr->lock, flags); | 548 | spin_lock_irqsave(&ctlr->lock, flags); |
548 | if (chan->state != CPDMA_STATE_IDLE) | 549 | if (chan->state != CPDMA_STATE_IDLE) |