From f9b21f5047b96957a8e24bc7d8692be6af1929c0 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 12 Jan 2008 01:03:42 +0000 Subject: drivers/media/common: Add missing video_device_release From: Julia Lawall 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/) // @@ 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; ) } // Signed-off-by: Julia Lawall CC: Oliver Endriss CC: Michael Hunold Signed-off-by: Andrew Morton Signed-off-by: Mauro Carvalho Chehab --- linux/drivers/media/common/saa7146_fops.c | 1 + 1 file changed, 1 insertion(+) (limited to 'linux/drivers/media/common/saa7146_fops.c') diff --git a/linux/drivers/media/common/saa7146_fops.c b/linux/drivers/media/common/saa7146_fops.c index b0bed2fbb..772b842bf 100644 --- a/linux/drivers/media/common/saa7146_fops.c +++ b/linux/drivers/media/common/saa7146_fops.c @@ -539,6 +539,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; } -- cgit v1.2.3