• Julia Lawall's avatar
    drivers/char/ppdev.c: put gotten port value · d98808a2
    Julia Lawall authored
    parport_find_number() calls parport_get_port() on its result, so there
    should be a corresponding call to parport_put_port() before dropping the
    reference.  Similar code is found in the function register_device() in the
    same file.
    
    The semantic match that finds this problem is as follows:
    (http://coccinelle.lip6.fr/)
    
      // <smpl>
      @exists@
      local idexpression struct parport * x;
      expression ra,rr;
      statement S1,S2;
      @@
    
      x = parport_find_number(...)
      ... when != x = rr
          when any
          when != parport_put_port(x,...)
          when != if (...) { ... parport_put_port(x,...) ...}
      (
      if(<+...x...+>) S1 else S2
      |
      if(...) { ... when != x = ra
           when forall
           when != parport_put_port(x,...)
      *return...;
      }
      )
      // </smpl>
    Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    d98808a2
ppdev.c 19.2 KB