aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-02-12 19:52:31 -0500
committerDavid S. Miller <davem@davemloft.net>2009-02-12 19:52:31 -0500
commit501aa061bd68169a5b54c123641f8dfa9ad31545 (patch)
treec3824d1b8e3085566748b29fbfd9186d916119a3 /drivers
parentf82da723398ff18d49275a5f03de6cae5f592e8e (diff)
3c505: do not set pcb->data.raw beyond its size
Ensure that we do not set pcb->data.raw beyond its size, print an error message and return false if we attempt to. A timout message was printed one too early. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/3c505.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 6124605bef05..a8107f992fb4 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -493,21 +493,27 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
493 } 493 }
494 /* read the data */ 494 /* read the data */
495 spin_lock_irqsave(&adapter->lock, flags); 495 spin_lock_irqsave(&adapter->lock, flags);
496 i = 0; 496 for (i = 0; i < MAX_PCB_DATA; i++) {
497 do { 497 for (j = 0; j < 20000; j++) {
498 j = 0; 498 stat = get_status(dev->base_addr);
499 while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000); 499 if (stat & ACRF)
500 pcb->data.raw[i++] = inb_command(dev->base_addr); 500 break;
501 if (i > MAX_PCB_DATA) 501 }
502 INVALID_PCB_MSG(i); 502 pcb->data.raw[i] = inb_command(dev->base_addr);
503 } while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000); 503 if ((stat & ASF_PCB_MASK) == ASF_PCB_END || j >= 20000)
504 break;
505 }
504 spin_unlock_irqrestore(&adapter->lock, flags); 506 spin_unlock_irqrestore(&adapter->lock, flags);
507 if (i >= MAX_PCB_DATA) {
508 INVALID_PCB_MSG(i);
509 return false;
510 }
505 if (j >= 20000) { 511 if (j >= 20000) {
506 TIMEOUT_MSG(__LINE__); 512 TIMEOUT_MSG(__LINE__);
507 return false; 513 return false;
508 } 514 }
509 /* woops, the last "data" byte was really the length! */ 515 /* the last "data" byte was really the length! */
510 total_length = pcb->data.raw[--i]; 516 total_length = pcb->data.raw[i];
511 517
512 /* safety check total length vs data length */ 518 /* safety check total length vs data length */
513 if (total_length != (pcb->length + 2)) { 519 if (total_length != (pcb->length + 2)) {