From: "Jules Maselbas" <jmaselbas@zdiv.net>
To: "Sascha Hauer" <s.hauer@pengutronix.de>,
"Barebox List" <barebox@lists.infradead.org>
Cc: "jianqiang wang" <wjq.sec@gmail.com>
Subject: Re: [PATCH v3 7/9] net: smc911x: do not read past the receive buffer
Date: Tue, 28 May 2024 15:29:47 +0200 [thread overview]
Message-ID: <D1LBBBUVTEKQ.21VMXYL98EK08@zdiv.net> (raw)
In-Reply-To: <20240528085806.1172689-8-s.hauer@pengutronix.de>
Hi,
On Tue May 28, 2024 at 10:58 AM CEST, Sascha Hauer wrote:
> The hardware may report a packet longer than our receive buffer. Instead
> of reading past the read buffer, discard too long packets.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/net/smc911x.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 1fca58ab84..8a0fa5cc25 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -460,14 +460,14 @@ static int smc911x_eth_rx(struct eth_device *edev)
> smc911x_reg_write(priv, RX_CFG, 0);
>
> tmplen = (pktlen + 3) / 4;
> - while(tmplen--)
> - *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
> -
> - if(status & RX_STS_ES)
> - dev_err(&edev->dev, "dropped bad packet. Status: 0x%08x\n",
> - status);
> - else
> - net_receive(edev, priv->rx_buf, pktlen);
I don't see a call to net_receive anymore
> +
> + if (pktlen > PKTSIZE || (status & RX_STS_ES)) {
> + while (tmplen--)
> + smc911x_reg_read(priv, RX_DATA_FIFO);
> + } else {
> + while (tmplen--)
> + *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
> + }
> }
>
> return 0;
next prev parent reply other threads:[~2024-05-28 13:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 8:57 [PATCH v3 0/9] net: do not read past " Sascha Hauer
2024-05-28 8:57 ` [PATCH v3 1/9] net: cs8900: simplify buffer read loop Sascha Hauer
2024-05-28 8:57 ` [PATCH v3 2/9] net: cs8900: do not read past the receive buffer Sascha Hauer
2024-05-28 8:58 ` [PATCH v3 3/9] net: ks8851_mll: " Sascha Hauer
2024-05-28 8:58 ` [PATCH v3 4/9] net: liteeth: " Sascha Hauer
2024-05-28 8:58 ` [PATCH v3 5/9] net: liteeth: do not set len to 0 before printing it Sascha Hauer
2024-05-28 8:58 ` [PATCH v3 6/9] net: smc911x: Fix amount of words read from RX FIFO Sascha Hauer
2024-05-28 8:58 ` [PATCH v3 7/9] net: smc911x: do not read past the receive buffer Sascha Hauer
2024-05-28 13:29 ` Jules Maselbas [this message]
2024-05-28 14:23 ` [PATCH] fixup! " Sascha Hauer
2024-05-28 14:26 ` [PATCH v3 7/9] " Sascha Hauer
2024-05-28 14:37 ` Jules Maselbas
2024-05-28 8:58 ` [PATCH v3 8/9] net: ks8851_mll: drop return value from ks8851_rx_frame() Sascha Hauer
2024-05-28 8:58 ` [PATCH v3 9/9] net: let net rx hook return void Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D1LBBBUVTEKQ.21VMXYL98EK08@zdiv.net \
--to=jmaselbas@zdiv.net \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
--cc=wjq.sec@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox