aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/atm/ueagle-atm.c
diff options
context:
space:
mode:
authormatthieu castet <castet.matthieu@free.fr>2005-11-07 18:02:30 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-01-04 16:48:29 -0500
commit8d7802ed3c617120863f84346638d1cf1c96137b (patch)
tree008b4724dd19719a3541651a8e68a250a5ecf587 /drivers/usb/atm/ueagle-atm.c
parentb72458a80c75cab832248f536412f386e20a93a0 (diff)
[PATCH] USB: Eagle and ADI 930 usb adsl modem driver fix
More care on loading firmware, take into account fw->size can't be zero. Signed-off-by: Matthieu CASTET <castet.matthieu@free.fr> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/atm/ueagle-atm.c')
-rw-r--r--drivers/usb/atm/ueagle-atm.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 3e2475c666ab..be08e16df09f 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -426,14 +426,14 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
426 426
427 pfw = fw_entry->data; 427 pfw = fw_entry->data;
428 size = fw_entry->size; 428 size = fw_entry->size;
429 if (size < 4)
430 goto err_fw_corrupted;
429 431
430 crc = FW_GET_LONG(pfw); 432 crc = FW_GET_LONG(pfw);
431 pfw += 4; 433 pfw += 4;
432 size -= 4; 434 size -= 4;
433 if (crc32_be(0, pfw, size) != crc) { 435 if (crc32_be(0, pfw, size) != crc)
434 uea_err(usb, "firmware is corrupted\n"); 436 goto err_fw_corrupted;
435 goto err;
436 }
437 437
438 /* 438 /*
439 * Start to upload formware : send reset 439 * Start to upload formware : send reset
@@ -446,9 +446,14 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
446 goto err; 446 goto err;
447 } 447 }
448 448
449 while (size > 0) { 449 while (size > 3) {
450 u8 len = FW_GET_BYTE(pfw); 450 u8 len = FW_GET_BYTE(pfw);
451 u16 add = FW_GET_WORD(pfw + 1); 451 u16 add = FW_GET_WORD(pfw + 1);
452
453 size -= len + 3;
454 if (size < 0)
455 goto err_fw_corrupted;
456
452 ret = uea_send_modem_cmd(usb, add, len, pfw + 3); 457 ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
453 if (ret < 0) { 458 if (ret < 0) {
454 uea_err(usb, "uploading firmware data failed " 459 uea_err(usb, "uploading firmware data failed "
@@ -456,9 +461,11 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
456 goto err; 461 goto err;
457 } 462 }
458 pfw += len + 3; 463 pfw += len + 3;
459 size -= len + 3;
460 } 464 }
461 465
466 if (size != 0)
467 goto err_fw_corrupted;
468
462 /* 469 /*
463 * Tell the modem we finish : de-assert reset 470 * Tell the modem we finish : de-assert reset
464 */ 471 */
@@ -469,6 +476,11 @@ static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *conte
469 else 476 else
470 uea_info(usb, "firmware uploaded\n"); 477 uea_info(usb, "firmware uploaded\n");
471 478
479 uea_leaves(usb);
480 return;
481
482err_fw_corrupted:
483 uea_err(usb, "firmware is corrupted\n");
472err: 484err:
473 uea_leaves(usb); 485 uea_leaves(usb);
474} 486}
@@ -522,10 +534,6 @@ static int check_dsp(u8 *dsp, unsigned int len)
522 u32 pageoffset; 534 u32 pageoffset;
523 unsigned int i, j, p, pp; 535 unsigned int i, j, p, pp;
524 536
525 /* enough space for pagecount? */
526 if (len < 1)
527 return 1;
528
529 pagecount = FW_GET_BYTE(dsp); 537 pagecount = FW_GET_BYTE(dsp);
530 p = 1; 538 p = 1;
531 539