[media] drivers/media/platform/mx2_emmaprp.c: use devm_kzalloc and devm_clk_get
authorJulia Lawall <Julia.Lawall@lip6.fr>
Tue, 14 Aug 2012 12:23:06 +0000 (09:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 15 Aug 2012 21:58:52 +0000 (18:58 -0300)
commitd1bb4b29a74ea81b8282011479bc36417620b5fa
tree8ef2d16603990d90c67fa782d09bd9d1a4845959
parent071408b6dcc1cb29150699621e13b0ddb81e3cf1
[media] drivers/media/platform/mx2_emmaprp.c: use devm_kzalloc and devm_clk_get

Using devm_kzalloc simplifies the code and ensures that the use of
devm_request_irq is safe.  When kzalloc and kfree were used, the interrupt
could be triggered after the handler's data argument had been freed.

This also introduces some missing initializations of the return variable
ret, and uses devm_request_and_ioremap instead of the combination of
devm_request_mem_region and devm_ioremap.

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: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/platform/mx2_emmaprp.c