Skip to contentSkip to conversation

tcp: fix error return code in tcp_xmit_probe_skb

PATCH In review Hongbin Wang 2 participants 2 messages Apr 14, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp: fix error return code in tcp_xmit_probe_skb

When alloc_skb failed, should return ENOMEM

---
 net/ipv4/tcp_output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -1
index c221f3bce975..b97c85814d9c 100644
@@ -3996,7 +3996,7 @@ static int tcp_xmit_probe_skb(struct sock *sk, int urgent, int mib)
 	skb = alloc_skb(MAX_TCP_HEADER,
 			sk_gfp_mask(sk, GFP_ATOMIC | __GFP_NOWARN));
 	if (!skb)
-		return -1;
+		return -ENOMEM;
 
 	/* Reserve space for headers and set control bits. */
 	skb_reserve(skb, MAX_TCP_HEADER);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 2 lines · Hongbin Wang

When alloc_skb failed, should return ENOMEM

Can you explain which rule mandates this statement ?

The only caller that propagates this error has other "return -1;"

The precise value of the error, we do not care, as long it is negative.

To be clear, this error code is not propagated to user space, so this patch only adds code churn.

Quoted 23 lines
---
 net/ipv4/tcp_output.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/tcp_output.c +1 -2
index c221f3bce975..b97c85814d9c 100644
@@ -3996,7 +3996,7 @@ static int tcp_xmit_probe_skb(struct sock *sk, int urgent, int mib)
        skb = alloc_skb(MAX_TCP_HEADER,
                        sk_gfp_mask(sk, GFP_ATOMIC | __GFP_NOWARN));
        if (!skb)
-               return -1;
+               return -ENOMEM;
 
        /* Reserve space for headers and set control bits. */
        skb_reserve(skb, MAX_TCP_HEADER);
--

2.25.1