]>
Commit | Line | Data |
---|---|---|
68a30562 | 1 | From 3798522afcf58abbce6de67446fcae7a34ae919d Mon Sep 17 00:00:00 2001 |
d37e80a3 WB |
2 | From: Prasad J Pandit <pjp@fedoraproject.org> |
3 | Date: Thu, 22 Sep 2016 16:01:38 +0530 | |
68a30562 | 4 | Subject: [PATCH 5/7] net: imx: limit buffer descriptor count |
d37e80a3 WB |
5 | |
6 | i.MX Fast Ethernet Controller uses buffer descriptors to manage | |
7 | data flow to/fro receive & transmit queues. While transmitting | |
8 | packets, it could continue to read buffer descriptors if a buffer | |
9 | descriptor has length of zero and has crafted values in bd.flags. | |
10 | Set an upper limit to number of buffer descriptors. | |
11 | ||
12 | Reported-by: Li Qiang <liqiang6-s@360.cn> | |
13 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> | |
14 | --- | |
15 | hw/net/imx_fec.c | 6 ++++-- | |
16 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
17 | ||
18 | diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c | |
68a30562 | 19 | index 1c415ab..1d74827 100644 |
d37e80a3 WB |
20 | --- a/hw/net/imx_fec.c |
21 | +++ b/hw/net/imx_fec.c | |
68a30562 | 22 | @@ -220,6 +220,8 @@ static const VMStateDescription vmstate_imx_eth = { |
d37e80a3 WB |
23 | #define PHY_INT_PARFAULT (1 << 2) |
24 | #define PHY_INT_AUTONEG_PAGE (1 << 1) | |
25 | ||
26 | +#define IMX_MAX_DESC 1024 | |
27 | + | |
68a30562 | 28 | static void imx_eth_update(IMXFECState *s); |
d37e80a3 WB |
29 | |
30 | /* | |
68a30562 | 31 | @@ -402,12 +404,12 @@ static void imx_eth_update(IMXFECState *s) |
d37e80a3 WB |
32 | |
33 | static void imx_fec_do_tx(IMXFECState *s) | |
34 | { | |
35 | - int frame_size = 0; | |
36 | + int frame_size = 0, descnt = 0; | |
68a30562 | 37 | uint8_t frame[ENET_MAX_FRAME_SIZE]; |
d37e80a3 WB |
38 | uint8_t *ptr = frame; |
39 | uint32_t addr = s->tx_descriptor; | |
40 | ||
41 | - while (1) { | |
42 | + while (descnt++ < IMX_MAX_DESC) { | |
43 | IMXFECBufDesc bd; | |
44 | int len; | |
45 | ||
46 | -- | |
47 | 2.1.4 | |
48 |