From 41e847890acbee5db65430c1d4f8d7ac07813140 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Fri, 19 Dec 2008 18:11:25 +0100 Subject: Staging: go7007: Move a dereference below a NULL test In each case, if the NULL test is necessary, then the dereference should be moved below the NULL test. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/). The result has been modified to move the initialization of usb down closer to where it is used. // @@ type T; expression E; identifier i,fld; statement S; @@ - T i = E->fld; + T i; ... when != E when != i if (E == NULL) S + i = E->fld; // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/go7007/s2250-board.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/staging/go7007') diff --git a/drivers/staging/go7007/s2250-board.c b/drivers/staging/go7007/s2250-board.c index fb6845e37884..a60e19ce794f 100644 --- a/drivers/staging/go7007/s2250-board.c +++ b/drivers/staging/go7007/s2250-board.c @@ -149,7 +149,7 @@ static int go7007_usb_vendor_request(struct go7007 *go, u16 request, static int write_reg(struct i2c_client *client, u8 reg, u8 value) { struct go7007 *go = i2c_get_adapdata(client->adapter); - struct go7007_usb *usb = go->hpi_context; + struct go7007_usb *usb; int rc; int dev_addr = client->addr; u8 *buf; @@ -164,6 +164,7 @@ static int write_reg(struct i2c_client *client, u8 reg, u8 value) if (buf == NULL) return -ENOMEM; + usb = go->hpi_context; if (down_interruptible(&usb->i2c_lock) != 0) { printk(KERN_INFO "i2c lock failed\n"); return -EINTR; @@ -181,7 +182,7 @@ static int write_reg(struct i2c_client *client, u8 reg, u8 value) static int write_reg_fp(struct i2c_client *client, u16 addr, u16 val) { struct go7007 *go = i2c_get_adapdata(client->adapter); - struct go7007_usb *usb = go->hpi_context; + struct go7007_usb *usb; u8 *buf; struct s2250 *dec = i2c_get_clientdata(client); @@ -200,6 +201,7 @@ static int write_reg_fp(struct i2c_client *client, u16 addr, u16 val) memset(buf, 0xcd, 6); + usb = go->hpi_context; if (down_interruptible(&usb->i2c_lock) != 0) { printk(KERN_INFO "i2c lock failed\n"); return -EINTR; -- cgit v1.2.3 From 253d3b139a5aa1a27672eab96879c7e019bdb774 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 25 Dec 2008 21:09:57 +0100 Subject: Staging: go7007: introduce missing kfree Error handling code following a kmalloc should free the allocated data. The semantic match that finds the problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // @r exists@ local idexpression x; statement S; expression E; identifier f,l; position p1,p2; expression *ptr != NULL; @@ ( if ((x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...)) == NULL) S | x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...); ... if (x == NULL) S ) <... when != x when != if (...) { <+...x...+> } x->f = E ...> ( return \(0\|<+...x...+>\|ptr\); | return@p2 ...; ) @script:python@ p1 << r.p1; p2 << r.p2; @@ print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/go7007/s2250-board.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging/go7007') diff --git a/drivers/staging/go7007/s2250-board.c b/drivers/staging/go7007/s2250-board.c index a60e19ce794f..d333ea2cd774 100644 --- a/drivers/staging/go7007/s2250-board.c +++ b/drivers/staging/go7007/s2250-board.c @@ -167,6 +167,7 @@ static int write_reg(struct i2c_client *client, u8 reg, u8 value) usb = go->hpi_context; if (down_interruptible(&usb->i2c_lock) != 0) { printk(KERN_INFO "i2c lock failed\n"); + kfree(buf); return -EINTR; } rc = go7007_usb_vendor_request(go, 0x55, dev_addr, -- cgit v1.2.3 From c6f5af88438b3e22d56a6b2aafaee5ffc4bc030e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 17 Mar 2009 16:01:58 -0700 Subject: Staging: go7007: fix build error VID_TYPE_CAPTURE is a v4l1 thing only. Reported-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/staging/go7007/go7007-v4l2.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging/go7007') diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c index 868edb65e7bf..06cacd37bbd8 100644 --- a/drivers/staging/go7007/go7007-v4l2.c +++ b/drivers/staging/go7007/go7007-v4l2.c @@ -1827,7 +1827,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { static struct video_device go7007_template = { .name = "go7007", - .vfl_type = VID_TYPE_CAPTURE, .fops = &go7007_fops, .minor = -1, .release = go7007_vfl_release, -- cgit v1.2.3