net: esp: cleanup esp_output_tail_tcp() in case of unsupported ESPINTCP
Subsystems (3)
PATCH v2 1/1 net: esp: cleanup esp_output_tail_tcp() in case of unsupported ESPINTCP
xmit() functions should consume skb or return error codes in error paths.
When the configuration "CONFIG_INET_ESPINTCP" is not set, the implementation of the function "esp_output_tail_tcp" violates this rule. The function frees the skb and returns the error code.
This change removes the kfree_skb from both functions, for both esp4 and esp6.WARN_ON is added because esp_output_tail_tcp() should never be called if CONFIG_INET_ESPINTCP is not set.
This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc.
--- net/ipv4/esp4.c | 3 +-- net/ipv6/esp6.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
net/ipv4/esp4.c +1 -2
@@ -238,8 +238,7 @@ static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb)#else static int esp_output_tail_tcp (struct xfrm_state *x,struct sk_buff *skb) { -kfree_skb (skb); - +WARN_ON (1 );return -EOPNOTSUPP ; }#endif
net/ipv6/esp6.c +1 -2
@@ -255,8 +255,7 @@ static int esp_output_tail_tcp(struct xfrm_state *x, struct sk_buff *skb)#else static int esp_output_tail_tcp (struct xfrm_state *x,struct sk_buff *skb) { -kfree_skb (skb); - +WARN_ON (1 );return -EOPNOTSUPP ; }#endif
Signature · 1 line
2.40.1
Steffen Klassert
maintainerQuoted 10 lines · Hagar Hemdan
xmit()functions should consume skb or return error codes in error paths.
When the configuration "CONFIG_INET_ESPINTCP" is not set, the implementation of the function "esp_output_tail_tcp" violates this rule. The function frees the skb and returns the error code.
This change removes thekfree_skbfrom both functions, for both esp4 and esp6.WARN_ONis added becauseesp_output_tail_tcp()should never be called ifCONFIG_INET_ESPINTCPis not set.
Quoted 5 lines
This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc.
Fixes e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")Signed-off-by Hagar Hemdan <[email protected]>
Patch applied, thanks a lot!