]> git.karo-electronics.de Git - karo-tx-linux.git/commit
i2c-smbus: Convert kzalloc to devm_kzalloc
authorJulia Lawall <Julia.Lawall@lip6.fr>
Mon, 10 Sep 2012 00:08:49 +0000 (10:08 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Mon, 10 Sep 2012 00:10:06 +0000 (10:10 +1000)
commit86a878d0946e9fe597ec482b115299b2c6a21478
tree5ef0b2d1719738877183bff642faf70ea0e51d61
parent89ce11c5c81ee24903c041e7012218e25260148a
i2c-smbus: Convert kzalloc to devm_kzalloc

Converting kzalloc to devm_kzalloc simplifies the code and ensures that the
result, alert, is freed after the irq allocated by the subsequent
devm_request_irq.  This in turn ensures that when an interrupt can be
triggered, the alert structure is still available.

The problem of a free after a devm_request_irq was found using the
following semantic match (http://coccinelle.lip6.fr/)

// <smpl>
@r exists@
expression e1,e2,x,a,b,c,d;
identifier free;
position p1,p2;
@@

  devm_request_irq@p1(e1,e2,...,x)
  ... when any
      when != e2 = a
      when != x = b
  if (...) {
    ... when != e2 = c
        when != x = d
    free@p2(...,x,...);
    ...
    return ...;
  }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/i2c-smbus.c