[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for v2.6.0] net: imx: check buffer descriptor le
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH for v2.6.0] net: imx: check buffer descriptor length |
Date: |
Wed, 21 Sep 2016 18:48:09 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
On 21/09/2016 15:45, P J P wrote:
> From: Prasad J Pandit <address@hidden>
>
> i.MX Fast Ethernet Controller uses buffer descriptors to manage
> data flow to/fro receive & transmit queues. While transmitting
> packets, it could continue to read buffer descriptors if a buffer
> descriptor has length of zero. Add check to avoid it.
>
> Reported-by: Li Qiang <address@hidden>
> Signed-off-by: Prasad J Pandit <address@hidden>
> ---
> hw/net/imx_fec.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
> index e60e338..31870b0 100644
> --- a/hw/net/imx_fec.c
> +++ b/hw/net/imx_fec.c
> @@ -276,7 +276,7 @@ static void imx_fec_do_tx(IMXFECState *s)
> imx_fec_read_bd(&bd, addr);
> FEC_PRINTF("tx_bd %x flags %04x len %d data %08x\n",
> addr, bd.flags, bd.length, bd.data);
> - if ((bd.flags & FEC_BD_R) == 0) {
> + if (!bd.length || (bd.flags & FEC_BD_R) == 0) {
> /* Run out of descriptors to transmit. */
> break;
> }
>
Same here---and same bug as the previous patch too:
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
index 1c415ab..50c7564 100644
--- a/hw/net/imx_fec.c
+++ b/hw/net/imx_fec.c
@@ -429,7 +429,7 @@ static void imx_fec_do_tx(IMXFECState *s)
frame_size += len;
if (bd.flags & ENET_BD_L) {
/* Last buffer in frame. */
- qemu_send_packet(qemu_get_queue(s->nic), frame, len);
+ qemu_send_packet(qemu_get_queue(s->nic), frame, frame_size);
ptr = frame;
frame_size = 0;
s->regs[ENET_EIR] |= ENET_INT_TXF;
Paolo