qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: deller@kernel.org
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>,
	Helge Deller <deller@gmx.de>
Subject: [PULL 4/7] i82596: Adding proper break-statement functionality in RX functions
Date: Sun,  9 Nov 2025 23:06:51 +0100	[thread overview]
Message-ID: <20251109220654.46718-5-deller@kernel.org> (raw)
In-Reply-To: <20251109220654.46718-1-deller@kernel.org>

From: Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>

Fix coverty reported logic error CID 1642873.
The initial issue was the break statement exited out of the for loop
unconditionally.
Now, the break only happens if rfd is null, out_of_resources or
bytes_copied < payload_size.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
Reviewed-by: Helge Deller <deller@gmx.de>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 hw/net/i82596.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/net/i82596.c b/hw/net/i82596.c
index fb6b54fd71..af1abd4996 100644
--- a/hw/net/i82596.c
+++ b/hw/net/i82596.c
@@ -1092,6 +1092,7 @@ static ssize_t i82596_receive_packet(I82596State *s, const uint8_t *buf,
                     rx_status |= RFD_STATUS_TRUNC | RFD_STATUS_NOBUFS;
                     i82596_record_error(s, RFD_STATUS_NOBUFS, false);
                     packet_completed = true;
+                    break;
                 } else {
                     hwaddr remaining_rbd = I596_NULL;
                     size_t rbd_bytes = i82596_rx_copy_to_rbds(
@@ -1118,17 +1119,18 @@ static ssize_t i82596_receive_packet(I82596State *s, const uint8_t *buf,
                         i82596_record_error(s, RFD_STATUS_NOBUFS, false);
                         rx_status |= RFD_STATUS_TRUNC | RFD_STATUS_NOBUFS;
                         packet_completed = true;
+                        break;
                     }
 
                     if (bytes_copied < payload_size) {
                         trace_i82596_rx_incomplete(bytes_copied, payload_size);
                         rx_status |= RFD_STATUS_TRUNC;
                         packet_completed = true;
+                        break;
                     }
                 }
             }
         }
-        break;
 
     } while (bytes_copied < payload_size);
 
-- 
2.51.1



  parent reply	other threads:[~2025-11-09 22:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-09 22:06 [PULL 0/7] Lasi fixes patches deller
2025-11-09 22:06 ` [PULL 1/7] ncr710: Fix potential null pointer dereference deller
2025-11-09 22:06 ` [PULL 2/7] ncr710: Drop leftover debug code deller
2025-11-09 22:06 ` [PULL 3/7] i82596: Remove crc_valid variable deller
2025-11-09 22:06 ` deller [this message]
2025-11-09 22:06 ` [PULL 5/7] ncr710: Add missing vmstate entries deller
2025-11-09 22:06 ` [PULL 6/7] ncr710: Use address space of device instead of global address space deller
2025-11-10 14:32 ` [PULL 0/7] Lasi fixes patches Richard Henderson

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=20251109220654.46718-5-deller@kernel.org \
    --to=deller@kernel.org \
    --cc=deller@gmx.de \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=soumyajyotisarkar23@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;
as well as URLs for NNTP newsgroup(s).