Skip to contentSkip to conversation

virt: sev-guest: Remove unnecessary free in init_crypto()

PATCH Applied Rafael Mendonca 2 participants 2 messages Oct 18, 2022 – Oct 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virt: sev-guest: Remove unnecessary free in init_crypto()

If the memory allocation for the auth tag fails, then there is no need to free it.

Fixes fce96cf04430 ("virt: Add SEV-SNP guest driver")
---
 drivers/virt/coco/sev-guest/sev-guest.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/virt/coco/sev-guest/sev-guest.c +1 -3
index f422f9c58ba7..e9704aecd7ee 100644
@@ -152,12 +152,10 @@ static struct snp_guest_crypto *init_crypto(struct snp_guest_dev *snp_dev, u8 *k
 	crypto->a_len = crypto_aead_authsize(crypto->tfm);
 	crypto->authtag = kmalloc(crypto->a_len, GFP_KERNEL_ACCOUNT);
 	if (!crypto->authtag)
-		goto e_free_auth;
+		goto e_free_iv;
 
 	return crypto;
 
-e_free_auth:
-	kfree(crypto->authtag);
 e_free_iv:
 	kfree(crypto->iv);
 e_free_crypto:
Signature · 1 line
2.34.1
#1 lore raw

[tip: x86/sev] virt/sev-guest: Remove unnecessary free in init_crypto()

The following commit has been merged into the x86/sev branch of tip:

The following commit has been merged into the x86/sev branch of tip:

Commit-ID:     c6fbb759d68898aad40e57d09ed18df6094a1874
Gitweb:        https://git.kernel.org/tip/c6fbb759d68898aad40e57d09ed18df6094a1874
Author:        Rafael Mendonca <[email protected]>
AuthorDate:    Mon, 17 Oct 2022 22:54:25 -03:00
Committer:     Borislav Petkov <[email protected]>
CommitterDate: Thu, 27 Oct 2022 14:24:18 +02:00

virt/sev-guest: Remove unnecessary free in init_crypto()

If the memory allocation for the auth tag fails, then there is no need to free it.

Fixes fce96cf04430 ("virt: Add SEV-SNP guest driver")
---
 drivers/virt/coco/sev-guest/sev-guest.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/virt/coco/sev-guest/sev-guest.c +1 -3
index f422f9c..e9704ae 100644
@@ -152,12 +152,10 @@ static struct snp_guest_crypto *init_crypto(struct snp_guest_dev *snp_dev, u8 *k
 	crypto->a_len = crypto_aead_authsize(crypto->tfm);
 	crypto->authtag = kmalloc(crypto->a_len, GFP_KERNEL_ACCOUNT);
 	if (!crypto->authtag)
-		goto e_free_auth;
+		goto e_free_iv;
 
 	return crypto;
 
-e_free_auth:
-	kfree(crypto->authtag);
 e_free_iv:
 	kfree(crypto->iv);
 e_free_crypto: