[PATCH 2/3] smb: client: Improve resource release in smb311_crypto_shash_allocate()

Markus Elfring posted 3 patches 2 months, 1 week ago
[PATCH 2/3] smb: client: Improve resource release in smb311_crypto_shash_allocate()
Posted by Markus Elfring 2 months, 1 week ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 9 Oct 2025 19:00:11 +0200

Adjust jump targets so that cifs_free_hash() functions will be called
in a recommended order at the end of this function implementation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 fs/smb/client/smb2transport.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c
index 499b00c2a001..b790f6b970a9 100644
--- a/fs/smb/client/smb2transport.c
+++ b/fs/smb/client/smb2transport.c
@@ -58,16 +58,17 @@ smb311_crypto_shash_allocate(struct TCP_Server_Info *server)
 
 	rc = cifs_alloc_hash("cmac(aes)", &p->aes_cmac);
 	if (rc)
-		goto err;
+		goto free_hmacsha256;
 
 	rc = cifs_alloc_hash("sha512", &p->sha512);
 	if (rc)
-		goto err;
+		goto free_aes_cmac;
 
 	return 0;
 
-err:
+free_aes_cmac:
 	cifs_free_hash(&p->aes_cmac);
+free_hmacsha256:
 	cifs_free_hash(&p->hmacsha256);
 	return rc;
 }
-- 
2.51.0