netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: adi: adin1110: Fix some error handling path in adin1110_read_fifo()
@ 2024-10-03 18:53 Christophe JAILLET
  2024-10-04 11:37 ` Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Christophe JAILLET @ 2024-10-03 18:53 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Lennart Franzen, Alexandru Tachici
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev

If 'frame_size' is too small or if 'round_len' is an error code, it is
likely that an error code should be returned to the caller.

Actually, 'ret' is likely to be 0, so if one of these sanity checks fails,
'success' is returned.

Return -EINVAL instead.

Fixes: bc93e19d088b ("net: ethernet: adi: Add ADIN1110 support")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative.
If returning 0 is what was intended, then an explicit 0 would be better.
---
 drivers/net/ethernet/adi/adin1110.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/adi/adin1110.c b/drivers/net/ethernet/adi/adin1110.c
index 3431a7e62b0d..c04036b687dd 100644
--- a/drivers/net/ethernet/adi/adin1110.c
+++ b/drivers/net/ethernet/adi/adin1110.c
@@ -318,11 +318,11 @@ static int adin1110_read_fifo(struct adin1110_port_priv *port_priv)
 	 * from the  ADIN1110 frame header.
 	 */
 	if (frame_size < ADIN1110_FRAME_HEADER_LEN + ADIN1110_FEC_LEN)
-		return ret;
+		return -EINVAL;
 
 	round_len = adin1110_round_len(frame_size);
 	if (round_len < 0)
-		return ret;
+		return -EINVAL;
 
 	frame_size_no_fcs = frame_size - ADIN1110_FRAME_HEADER_LEN - ADIN1110_FEC_LEN;
 	memset(priv->data, 0, ADIN1110_RD_HEADER_LEN);
-- 
2.46.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-10-08  0:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 18:53 [PATCH net] net: ethernet: adi: adin1110: Fix some error handling path in adin1110_read_fifo() Christophe JAILLET
2024-10-04 11:37 ` Simon Horman
2024-10-04 13:15   ` Christophe JAILLET
2024-10-07 15:45     ` Simon Horman
2024-10-04 11:47 ` Dan Carpenter
2024-10-04 13:27   ` Christophe JAILLET
2024-10-04 18:09   ` Jakub Kicinski
2024-10-07 15:46     ` Simon Horman
2024-10-07 17:35       ` Julia Lawall
2024-10-08  0:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).