aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/gspca/pac207.c
diff options
context:
space:
mode:
authorJean-Francois Moine <moinejf@free.fr>2008-07-14 08:38:29 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:26:14 -0400
commit739570bb218bb4607df1f197282561e97a98e54a (patch)
tree25555dfe5ac873bc96866c486d6f6c1dcabf24f4 /drivers/media/video/gspca/pac207.c
parent5b77ae7776183d733ec86727bcc34c52a336afd6 (diff)
V4L/DVB (8352): gspca: Buffers for USB exchanges cannot be in the stack.
gspca: Protect dq_callback() against simultaneous USB exchanges. Temporary buffer for USB exchanges added in the device struct. (all) Use a temporary buffer for all USB exchanges. Signed-off-by: Jean-Francois Moine <moinejf@free.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/gspca/pac207.c')
-rw-r--r--drivers/media/video/gspca/pac207.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/media/video/gspca/pac207.c b/drivers/media/video/gspca/pac207.c
index 5d68d3f42262..fa7abc411090 100644
--- a/drivers/media/video/gspca/pac207.c
+++ b/drivers/media/video/gspca/pac207.c
@@ -27,8 +27,8 @@
27 27
28#include "gspca.h" 28#include "gspca.h"
29 29
30#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) 30#define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7)
31static const char version[] = "2.1.5"; 31static const char version[] = "2.1.7";
32 32
33MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>"); 33MODULE_AUTHOR("Hans de Goede <j.w.r.degoede@hhs.nl>");
34MODULE_DESCRIPTION("Pixart PAC207"); 34MODULE_DESCRIPTION("Pixart PAC207");
@@ -187,18 +187,18 @@ static const __u8 PacReg72[] = { 0x00, 0x00, 0x36, 0x00 };
187static const unsigned char pac207_sof_marker[5] = 187static const unsigned char pac207_sof_marker[5] =
188 { 0xff, 0xff, 0x00, 0xff, 0x96 }; 188 { 0xff, 0xff, 0x00, 0xff, 0x96 };
189 189
190int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index, 190static int pac207_write_regs(struct gspca_dev *gspca_dev, u16 index,
191 const u8 *buffer, u16 length) 191 const u8 *buffer, u16 length)
192{ 192{
193 struct usb_device *udev = gspca_dev->dev; 193 struct usb_device *udev = gspca_dev->dev;
194 int err; 194 int err;
195 u8 kbuf[8];
196 195
197 memcpy(kbuf, buffer, length); 196 memcpy(gspca_dev->usb_buf, buffer, length);
198 197
199 err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x01, 198 err = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x01,
200 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 199 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
201 0x00, index, kbuf, length, PAC207_CTRL_TIMEOUT); 200 0x00, index,
201 gspca_dev->usb_buf, length, PAC207_CTRL_TIMEOUT);
202 if (err < 0) 202 if (err < 0)
203 PDEBUG(D_ERR, 203 PDEBUG(D_ERR,
204 "Failed to write registers to index 0x%04X, error %d)", 204 "Failed to write registers to index 0x%04X, error %d)",
@@ -227,12 +227,12 @@ int pac207_write_reg(struct gspca_dev *gspca_dev, u16 index, u16 value)
227int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index) 227int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
228{ 228{
229 struct usb_device *udev = gspca_dev->dev; 229 struct usb_device *udev = gspca_dev->dev;
230 u8 buff;
231 int res; 230 int res;
232 231
233 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 232 res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00,
234 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 233 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
235 0x00, index, &buff, 1, PAC207_CTRL_TIMEOUT); 234 0x00, index,
235 gspca_dev->usb_buf, 1, PAC207_CTRL_TIMEOUT);
236 if (res < 0) { 236 if (res < 0) {
237 PDEBUG(D_ERR, 237 PDEBUG(D_ERR,
238 "Failed to read a register (index 0x%04X, error %d)", 238 "Failed to read a register (index 0x%04X, error %d)",
@@ -240,10 +240,9 @@ int pac207_read_reg(struct gspca_dev *gspca_dev, u16 index)
240 return res; 240 return res;
241 } 241 }
242 242
243 return buff; 243 return gspca_dev->usb_buf[0];
244} 244}
245 245
246
247/* this function is called at probe time */ 246/* this function is called at probe time */
248static int sd_config(struct gspca_dev *gspca_dev, 247static int sd_config(struct gspca_dev *gspca_dev,
249 const struct usb_device_id *id) 248 const struct usb_device_id *id)