diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-21 09:53:18 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-21 10:47:02 -0500 |
commit | 711e1398d3131fd83aee0a35d450c6e1a809bfb2 (patch) | |
tree | 06c43c8ef3278f27c6d1009b99b32f7b1125200c /drivers/media/dvb/dvb-usb/az6007.c | |
parent | a2c35d346d9e9555db930f9035d0e628bf7f3393 (diff) |
[media] az6007: Be sure to use kmalloc'ed buffer for transfers
USB data transfers may not work if the buffer is allocated at
the stack. Be sure to use kmalloc on all places where a buffer
is needed.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb/az6007.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/az6007.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/drivers/media/dvb/dvb-usb/az6007.c b/drivers/media/dvb/dvb-usb/az6007.c index 6177332a7a0e..142ef7b0c02e 100644 --- a/drivers/media/dvb/dvb-usb/az6007.c +++ b/drivers/media/dvb/dvb-usb/az6007.c | |||
@@ -201,8 +201,8 @@ static struct rc_map_table rc_map_az6007_table[] = { | |||
201 | /* remote control stuff (does not work with my box) */ | 201 | /* remote control stuff (does not work with my box) */ |
202 | static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state) | 202 | static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state) |
203 | { | 203 | { |
204 | struct az6007_device_state *st = d->priv; | ||
204 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; | 205 | struct rc_map_table *keymap = d->props.rc.legacy.rc_map_table; |
205 | u8 key[10]; | ||
206 | int i; | 206 | int i; |
207 | 207 | ||
208 | /* | 208 | /* |
@@ -212,9 +212,9 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state) | |||
212 | */ | 212 | */ |
213 | return 0; | 213 | return 0; |
214 | 214 | ||
215 | az6007_read(d, AZ6007_READ_IR, 0, 0, key, 10); | 215 | az6007_read(d, AZ6007_READ_IR, 0, 0, st->data, 10); |
216 | 216 | ||
217 | if (key[1] == 0x44) { | 217 | if (st->data[1] == 0x44) { |
218 | *state = REMOTE_NO_KEY_PRESSED; | 218 | *state = REMOTE_NO_KEY_PRESSED; |
219 | return 0; | 219 | return 0; |
220 | } | 220 | } |
@@ -228,11 +228,11 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state) | |||
228 | * 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR) | 228 | * 88 80 7e 0d f2 ff 00 82 63 82 (another NEC-extended based IR) |
229 | * I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity | 229 | * I suspect that the IR data is at bytes 1 to 4, and byte 5 is parity |
230 | */ | 230 | */ |
231 | deb_rc("remote query key: %x %d\n", key[1], key[1]); | 231 | deb_rc("remote query key: %x %d\n", st->data[1], st->data[1]); |
232 | print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, key, 10); | 232 | print_hex_dump_bytes("Remote: ", DUMP_PREFIX_NONE, st->data, 10); |
233 | 233 | ||
234 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { | 234 | for (i = 0; i < d->props.rc.legacy.rc_map_size; i++) { |
235 | if (rc5_custom(&keymap[i]) == key[1]) { | 235 | if (rc5_custom(&keymap[i]) == st->data[1]) { |
236 | *event = keymap[i].keycode; | 236 | *event = keymap[i].keycode; |
237 | *state = REMOTE_KEY_PRESSED; | 237 | *state = REMOTE_KEY_PRESSED; |
238 | 238 | ||
@@ -244,8 +244,11 @@ static int az6007_rc_query(struct dvb_usb_device *d, u32 * event, int *state) | |||
244 | 244 | ||
245 | static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6]) | 245 | static int az6007_read_mac_addr(struct dvb_usb_device *d, u8 mac[6]) |
246 | { | 246 | { |
247 | struct az6007_device_state *st = d->priv; | ||
247 | int ret; | 248 | int ret; |
248 | ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, mac, 6); | 249 | |
250 | ret = az6007_read(d, AZ6007_READ_DATA, 6, 0, st->data, 6); | ||
251 | memcpy(mac, st->data, sizeof(mac)); | ||
249 | 252 | ||
250 | if (ret > 0) | 253 | if (ret > 0) |
251 | deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n", | 254 | deb_info("%s: mac is %02x:%02x:%02x:%02x:%02x:%02x\n", |
@@ -464,7 +467,11 @@ int az6007_identify_state(struct usb_device *udev, | |||
464 | struct dvb_usb_device_description **desc, int *cold) | 467 | struct dvb_usb_device_description **desc, int *cold) |
465 | { | 468 | { |
466 | int ret; | 469 | int ret; |
467 | u8 mac[6]; | 470 | u8 *mac; |
471 | |||
472 | mac = kmalloc(6, GFP_ATOMIC); | ||
473 | if (!mac) | ||
474 | return -ENOMEM; | ||
468 | 475 | ||
469 | /* Try to read the mac address */ | 476 | /* Try to read the mac address */ |
470 | ret = __az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6); | 477 | ret = __az6007_read(udev, AZ6007_READ_DATA, 6, 0, mac, 6); |
@@ -473,6 +480,8 @@ int az6007_identify_state(struct usb_device *udev, | |||
473 | else | 480 | else |
474 | *cold = 1; | 481 | *cold = 1; |
475 | 482 | ||
483 | kfree(mac); | ||
484 | |||
476 | if (*cold) { | 485 | if (*cold) { |
477 | __az6007_write(udev, 0x09, 1, 0, NULL, 0); | 486 | __az6007_write(udev, 0x09, 1, 0, NULL, 0); |
478 | __az6007_write(udev, 0x00, 0, 0, NULL, 0); | 487 | __az6007_write(udev, 0x00, 0, 0, NULL, 0); |
@@ -488,8 +497,6 @@ static struct dvb_usb_device_properties az6007_properties; | |||
488 | static int az6007_usb_probe(struct usb_interface *intf, | 497 | static int az6007_usb_probe(struct usb_interface *intf, |
489 | const struct usb_device_id *id) | 498 | const struct usb_device_id *id) |
490 | { | 499 | { |
491 | struct usb_device *udev = interface_to_usbdev(intf); | ||
492 | |||
493 | return dvb_usb_device_init(intf, &az6007_properties, | 500 | return dvb_usb_device_init(intf, &az6007_properties, |
494 | THIS_MODULE, NULL, adapter_nr); | 501 | THIS_MODULE, NULL, adapter_nr); |
495 | } | 502 | } |