Skip to content

Commit

Permalink
drivers/net/ethernet/ti/davinci_cpdma.c: Remove potential NULL derefe…
Browse files Browse the repository at this point in the history
…rence

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>
  • Loading branch information
Julia Lawall authored and David S. Miller committed Aug 14, 2012
1 parent aadf31d commit f37c54b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/ti/davinci_cpdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,11 +538,12 @@ EXPORT_SYMBOL_GPL(cpdma_chan_create);

int cpdma_chan_destroy(struct cpdma_chan *chan)
{
struct cpdma_ctlr *ctlr = chan->ctlr;
struct cpdma_ctlr *ctlr;
unsigned long flags;

if (!chan)
return -EINVAL;
ctlr = chan->ctlr;

spin_lock_irqsave(&ctlr->lock, flags);
if (chan->state != CPDMA_STATE_IDLE)
Expand Down

0 comments on commit f37c54b

Please sign in to comment.