diff mbox series

[1/1] net:tipc: check return value of pskb_trim()

Message ID 20230717145049.27642-1-ruc_gongyuanjun@163.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [1/1] net:tipc: check return value of pskb_trim() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1342 this patch: 1342
netdev/cc_maintainers warning 5 maintainers not CCed: kuba@kernel.org tipc-discussion@lists.sourceforge.net davem@davemloft.net pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 1365 this patch: 1365
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1365 this patch: 1365
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yuanjun Gong July 17, 2023, 2:50 p.m. UTC
goto free_skb if an unexpected result is returned by pskb_tirm()
in tipc_crypto_rcv_complete().

Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 net/tipc/crypto.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Kuniyuki Iwashima July 17, 2023, 6:57 p.m. UTC | #1
From: Yuanjun Gong <ruc_gongyuanjun@163.com>
Date: Mon, 17 Jul 2023 22:50:49 +0800
> goto free_skb if an unexpected result is returned by pskb_tirm()
> in tipc_crypto_rcv_complete().
> 
> Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
> ---
>  net/tipc/crypto.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
> index 577fa5af33ec..1b86cea261a5 100644
> --- a/net/tipc/crypto.c
> +++ b/net/tipc/crypto.c
> @@ -1894,6 +1894,7 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead,
>  	struct tipc_aead *tmp = NULL;
>  	struct tipc_ehdr *ehdr;
>  	struct tipc_node *n;
> +	int ret;
>  
>  	/* Is this completed by TX? */
>  	if (unlikely(is_tx(aead->crypto))) {
> @@ -1960,7 +1961,9 @@ static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead,
>  
>  	skb_reset_network_header(*skb);
>  	skb_pull(*skb, tipc_ehdr_size(ehdr));
> -	pskb_trim(*skb, (*skb)->len - aead->authsize);
> +	ret = pskb_trim(*skb, (*skb)->len - aead->authsize);
> +	if (ret)

No need to define ret.


> +		goto free_skb;
>  
>  	/* Validate TIPCv2 message */
>  	if (unlikely(!tipc_msg_validate(skb))) {
> -- 
> 2.17.1
diff mbox series

Patch

diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index 577fa5af33ec..1b86cea261a5 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -1894,6 +1894,7 @@  static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead,
 	struct tipc_aead *tmp = NULL;
 	struct tipc_ehdr *ehdr;
 	struct tipc_node *n;
+	int ret;
 
 	/* Is this completed by TX? */
 	if (unlikely(is_tx(aead->crypto))) {
@@ -1960,7 +1961,9 @@  static void tipc_crypto_rcv_complete(struct net *net, struct tipc_aead *aead,
 
 	skb_reset_network_header(*skb);
 	skb_pull(*skb, tipc_ehdr_size(ehdr));
-	pskb_trim(*skb, (*skb)->len - aead->authsize);
+	ret = pskb_trim(*skb, (*skb)->len - aead->authsize);
+	if (ret)
+		goto free_skb;
 
 	/* Validate TIPCv2 message */
 	if (unlikely(!tipc_msg_validate(skb))) {