The caller of batadv_frag_send_packet() assume that the skb provided to the
function are always consumed. But the pre-check for an empty payload or the
zero fragment size returned an error without any further actions.

A failed pre-check must use the same error handling code as the rest of the
function.

Fixes: db56e4ecf5c2 ("batman-adv: Fragment and send skbs larger than mtu")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 net/batman-adv/fragmentation.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index e2c74ae6..e9d2bbc4 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -524,8 +524,10 @@ int batadv_frag_send_packet(struct sk_buff *skb,
        mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
        max_fragment_size = mtu - header_size;
 
-       if (skb->len == 0 || max_fragment_size == 0)
-               return -EINVAL;
+       if (skb->len == 0 || max_fragment_size == 0) {
+               ret = -EAGAIN;
+               goto free_skb;
+       }
 
        num_fragments = (skb->len - 1) / max_fragment_size + 1;
        max_fragment_size = (skb->len - 1) / num_fragments + 1;

---
base-commit: 22b12d005035f37f898e5bf80480719fe1ef4fba
change-id: 20260703-frag-tx-always-consume-3c5002b6b916

Best regards,
--  
Sven Eckelmann <[email protected]>

Reply via email to