V4L/DVB (7035): drivers/media/common: Add missing video_device_release

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Friday, January 25, 2008 - 7:15 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a2a9b1...
Commit:     a2a9b1eceb50993ef9e126dffc2f678fd6602158
Parent:     bc835d80d9cd912cfa8beb6ad4549cd8160d3601
Author:     Julia Lawall <julia@diku.dk>
AuthorDate: Fri Jan 11 22:03:42 2008 -0300
Committer:  Mauro Carvalho Chehab <mchehab@infradead.org>
CommitDate: Fri Jan 25 19:05:02 2008 -0200

    V4L/DVB (7035): drivers/media/common: Add missing video_device_release
    
    Video_device_alloc returns the result of a kzalloc.  In this case, the
    value is stored in a local variable which is not copied elsewhere before
    the point of the error return (video_register_device does not save its
    first argument anywhere if it returns a negative value).  Thus, a
    video_device_release it needed before the error return.
    
    The problem was found using the following semantic match.
    (http://www.emn.fr/x-info/coccinelle/)
    
    // <smpl>
    @@
    type T,T1,T2;
    identifier E;
    statement S;
    expression x1,x2,x3;
    int ret;
    @@
    
      T E;
      ...
    * E = video_device_alloc(...);
      if (E == NULL) S
      ... when != video_device_release(...,(T1)E,...)
          when != if (E != NULL) { ... video_device_release(...,(T1)E,...); ...}
          when != x1 = (T1)E
          when != E = x3;
          when any
      if (...) {
        ... when != video_device_release(...,(T2)E,...)
            when != if (E != NULL) { ... video_device_release(...,(T2)E,...); ...}
            when != x2 = (T2)E
    (
    *   return;
    |
    *   return ret;
    )
      }
    // </smpl>
    
    Signed-off-by: Julia Lawall <julia@diku.dk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    CC: Oliver Endriss <o.endriss@gmx.de>
    CC: Michael Hunold <michael@mihu.de>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
 drivers/media/common/saa7146_fops.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index b40bf23..f0703d8 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -538,6 +538,7 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
 	// fixme: -1 should be an insmod parameter *for the extension* (like "video_nr");
 	if (video_register_device(vfd, type, -1) < 0) {
 		ERR(("cannot register v4l2 device. skipping.\n"));
+		video_device_release(vfd);
 		return -1;
 	}
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
V4L/DVB (7035): drivers/media/common: Add missing video_devi..., Linux Kernel Mailing List..., (Fri Jan 25, 7:15 pm)