diff options
author | Jean-Francois Moine <moinejf@free.fr> | 2008-07-14 08:38:29 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:26:14 -0400 |
commit | 739570bb218bb4607df1f197282561e97a98e54a (patch) | |
tree | 25555dfe5ac873bc96866c486d6f6c1dcabf24f4 /drivers/media/video/gspca/spca508.c | |
parent | 5b77ae7776183d733ec86727bcc34c52a336afd6 (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/spca508.c')
-rw-r--r-- | drivers/media/video/gspca/spca508.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/media/video/gspca/spca508.c b/drivers/media/video/gspca/spca508.c index 7f262f23841e..d8cd93866a4a 100644 --- a/drivers/media/video/gspca/spca508.c +++ b/drivers/media/video/gspca/spca508.c | |||
@@ -22,8 +22,8 @@ | |||
22 | 22 | ||
23 | #include "gspca.h" | 23 | #include "gspca.h" |
24 | 24 | ||
25 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 5) | 25 | #define DRIVER_VERSION_NUMBER KERNEL_VERSION(2, 1, 7) |
26 | static const char version[] = "2.1.5"; | 26 | static const char version[] = "2.1.7"; |
27 | 27 | ||
28 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); | 28 | MODULE_AUTHOR("Michel Xhaard <mxhaard@users.sourceforge.net>"); |
29 | MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver"); | 29 | MODULE_DESCRIPTION("GSPCA/SPCA508 USB Camera Driver"); |
@@ -1433,26 +1433,26 @@ static int reg_write(struct usb_device *dev, | |||
1433 | 1433 | ||
1434 | /* read 1 byte */ | 1434 | /* read 1 byte */ |
1435 | /* returns: negative is error, pos or zero is data */ | 1435 | /* returns: negative is error, pos or zero is data */ |
1436 | static int reg_read(struct usb_device *dev, | 1436 | static int reg_read(struct gspca_dev *gspca_dev, |
1437 | __u16 index) /* wIndex */ | 1437 | __u16 index) /* wIndex */ |
1438 | { | 1438 | { |
1439 | int ret; | 1439 | int ret; |
1440 | __u8 data; | ||
1441 | 1440 | ||
1442 | ret = usb_control_msg(dev, | 1441 | ret = usb_control_msg(gspca_dev->dev, |
1443 | usb_rcvctrlpipe(dev, 0), | 1442 | usb_rcvctrlpipe(gspca_dev->dev, 0), |
1444 | 0, /* register */ | 1443 | 0, /* register */ |
1445 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, | 1444 | USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, |
1446 | (__u16) 0, /* value */ | 1445 | 0, /* value */ |
1447 | index, | 1446 | index, |
1448 | &data, 1, | 1447 | gspca_dev->usb_buf, 1, |
1449 | 500); /* timeout */ | 1448 | 500); /* timeout */ |
1450 | PDEBUG(D_USBI, "reg read i:%04x --> %02x", index, data); | 1449 | PDEBUG(D_USBI, "reg read i:%04x --> %02x", |
1450 | index, gspca_dev->usb_buf[0]); | ||
1451 | if (ret < 0) { | 1451 | if (ret < 0) { |
1452 | PDEBUG(D_ERR|D_USBI, "reg_read err %d", ret); | 1452 | PDEBUG(D_ERR|D_USBI, "reg_read err %d", ret); |
1453 | return ret; | 1453 | return ret; |
1454 | } | 1454 | } |
1455 | return data; | 1455 | return gspca_dev->usb_buf[0]; |
1456 | } | 1456 | } |
1457 | 1457 | ||
1458 | static int write_vector(struct gspca_dev *gspca_dev, | 1458 | static int write_vector(struct gspca_dev *gspca_dev, |
@@ -1475,15 +1475,12 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1475 | const struct usb_device_id *id) | 1475 | const struct usb_device_id *id) |
1476 | { | 1476 | { |
1477 | struct sd *sd = (struct sd *) gspca_dev; | 1477 | struct sd *sd = (struct sd *) gspca_dev; |
1478 | struct usb_device *dev = gspca_dev->dev; | ||
1479 | struct cam *cam; | 1478 | struct cam *cam; |
1480 | __u16 vendor; | ||
1481 | __u16 product; | 1479 | __u16 product; |
1482 | int data1, data2; | 1480 | int data1, data2; |
1483 | 1481 | ||
1484 | vendor = id->idVendor; | ||
1485 | product = id->idProduct; | 1482 | product = id->idProduct; |
1486 | switch (vendor) { | 1483 | switch (id->idVendor) { |
1487 | case 0x0130: /* Clone webcam */ | 1484 | case 0x0130: /* Clone webcam */ |
1488 | /* switch (product) { */ | 1485 | /* switch (product) { */ |
1489 | /* case 0x0130: */ | 1486 | /* case 0x0130: */ |
@@ -1535,15 +1532,15 @@ static int sd_config(struct gspca_dev *gspca_dev, | |||
1535 | * prove that we can communicate with the device. This works, which | 1532 | * prove that we can communicate with the device. This works, which |
1536 | * confirms at we are communicating properly and that the device | 1533 | * confirms at we are communicating properly and that the device |
1537 | * is a 508. */ | 1534 | * is a 508. */ |
1538 | data1 = reg_read(dev, 0x8104); | 1535 | data1 = reg_read(gspca_dev, 0x8104); |
1539 | data2 = reg_read(dev, 0x8105); | 1536 | data2 = reg_read(gspca_dev, 0x8105); |
1540 | PDEBUG(D_PROBE, "Webcam Vendor ID: 0x%02x%02x", data2, data1); | 1537 | PDEBUG(D_PROBE, "Webcam Vendor ID: 0x%02x%02x", data2, data1); |
1541 | 1538 | ||
1542 | data1 = reg_read(dev, 0x8106); | 1539 | data1 = reg_read(gspca_dev, 0x8106); |
1543 | data2 = reg_read(dev, 0x8107); | 1540 | data2 = reg_read(gspca_dev, 0x8107); |
1544 | PDEBUG(D_PROBE, "Webcam Product ID: 0x%02x%02x", data2, data1); | 1541 | PDEBUG(D_PROBE, "Webcam Product ID: 0x%02x%02x", data2, data1); |
1545 | 1542 | ||
1546 | data1 = reg_read(dev, 0x8621); | 1543 | data1 = reg_read(gspca_dev, 0x8621); |
1547 | PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); | 1544 | PDEBUG(D_PROBE, "Window 1 average luminance: %d", data1); |
1548 | 1545 | ||
1549 | cam = &gspca_dev->cam; | 1546 | cam = &gspca_dev->cam; |
@@ -1711,7 +1708,7 @@ static void getbrightness(struct gspca_dev *gspca_dev) | |||
1711 | { | 1708 | { |
1712 | struct sd *sd = (struct sd *) gspca_dev; | 1709 | struct sd *sd = (struct sd *) gspca_dev; |
1713 | 1710 | ||
1714 | sd->brightness = reg_read(gspca_dev->dev, 0x8651); | 1711 | sd->brightness = reg_read(gspca_dev, 0x8651); |
1715 | } | 1712 | } |
1716 | 1713 | ||
1717 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) | 1714 | static int sd_setbrightness(struct gspca_dev *gspca_dev, __s32 val) |