diff options
Diffstat (limited to 'net/tipc/crypto.c')
| -rw-r--r-- | net/tipc/crypto.c | 23 | 
1 files changed, 8 insertions, 15 deletions
| diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index dc60c32bb70d..9325479295b8 100644 --- a/net/tipc/crypto.c +++ b/net/tipc/crypto.c @@ -597,6 +597,10 @@ static int tipc_aead_init(struct tipc_aead **aead, struct tipc_aead_key *ukey,  	tmp->cloned = NULL;  	tmp->authsize = TIPC_AES_GCM_TAG_SIZE;  	tmp->key = kmemdup(ukey, tipc_aead_key_size(ukey), GFP_KERNEL); +	if (!tmp->key) { +		tipc_aead_free(&tmp->rcu); +		return -ENOMEM; +	}  	memcpy(&tmp->salt, ukey->key + keylen, TIPC_AES_GCM_SALT_SIZE);  	atomic_set(&tmp->users, 0);  	atomic64_set(&tmp->seqno, 0); @@ -757,21 +761,10 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb,  			 skb_tailroom(skb), tailen);  	} -	if (unlikely(!skb_cloned(skb) && tailen <= skb_tailroom(skb))) { -		nsg = 1; -		trailer = skb; -	} else { -		/* TODO: We could avoid skb_cow_data() if skb has no frag_list -		 * e.g. by skb_fill_page_desc() to add another page to the skb -		 * with the wanted tailen... However, page skbs look not often, -		 * so take it easy now! -		 * Cloned skbs e.g. from link_xmit() seems no choice though :( -		 */ -		nsg = skb_cow_data(skb, tailen, &trailer); -		if (unlikely(nsg < 0)) { -			pr_err("TX: skb_cow_data() returned %d\n", nsg); -			return nsg; -		} +	nsg = skb_cow_data(skb, tailen, &trailer); +	if (unlikely(nsg < 0)) { +		pr_err("TX: skb_cow_data() returned %d\n", nsg); +		return nsg;  	}  	pskb_put(skb, trailer, tailen); |