mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
f82da72339
commit
501aa061bd
|
@ -493,21 +493,27 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
|
||||||
}
|
}
|
||||||
/* read the data */
|
/* read the data */
|
||||||
spin_lock_irqsave(&adapter->lock, flags);
|
spin_lock_irqsave(&adapter->lock, flags);
|
||||||
i = 0;
|
for (i = 0; i < MAX_PCB_DATA; i++) {
|
||||||
do {
|
for (j = 0; j < 20000; j++) {
|
||||||
j = 0;
|
stat = get_status(dev->base_addr);
|
||||||
while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && j++ < 20000);
|
if (stat & ACRF)
|
||||||
pcb->data.raw[i++] = inb_command(dev->base_addr);
|
break;
|
||||||
if (i > MAX_PCB_DATA)
|
}
|
||||||
INVALID_PCB_MSG(i);
|
pcb->data.raw[i] = inb_command(dev->base_addr);
|
||||||
} while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
|
if ((stat & ASF_PCB_MASK) == ASF_PCB_END || j >= 20000)
|
||||||
|
break;
|
||||||
|
}
|
||||||
spin_unlock_irqrestore(&adapter->lock, flags);
|
spin_unlock_irqrestore(&adapter->lock, flags);
|
||||||
|
if (i >= MAX_PCB_DATA) {
|
||||||
|
INVALID_PCB_MSG(i);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (j >= 20000) {
|
if (j >= 20000) {
|
||||||
TIMEOUT_MSG(__LINE__);
|
TIMEOUT_MSG(__LINE__);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/* woops, the last "data" byte was really the length! */
|
/* the last "data" byte was really the length! */
|
||||||
total_length = pcb->data.raw[--i];
|
total_length = pcb->data.raw[i];
|
||||||
|
|
||||||
/* safety check total length vs data length */
|
/* safety check total length vs data length */
|
||||||
if (total_length != (pcb->length + 2)) {
|
if (total_length != (pcb->length + 2)) {
|
||||||
|
|
Loading…
Reference in New Issue