public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sunrpc: Improve exception handling in krb5_etm_checksum()
@ 2023-12-31 13:56 Markus Elfring
  2024-01-01  2:18 ` Chuck Lever
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2023-12-31 13:56 UTC (permalink / raw)
  To: linux-nfs, netdev, kernel-janitors, Anna Schumaker,
	Ard Biesheuvel, Chuck Lever, Dai Ngo, David S. Miller,
	Eric Dumazet, Herbert Xu, Jakub Kicinski, Jeff Layton, Neil Brown,
	Olga Kornievskaia, Paolo Abeni, Simo Sorce, Tom Talpey,
	Trond Myklebust
  Cc: LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 31 Dec 2023 14:43:05 +0100

The kfree() function was called in one case by
the krb5_etm_checksum() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

Thus use another label.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/sunrpc/auth_gss/gss_krb5_crypto.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index d2b02710ab07..5e2dc3eb8545 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -942,7 +942,7 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher,
 	/* For RPCSEC, the "initial cipher state" is always all zeroes. */
 	iv = kzalloc(ivsize, GFP_KERNEL);
 	if (!iv)
-		goto out_free_mem;
+		goto out_free_checksum;

 	req = ahash_request_alloc(tfm, GFP_KERNEL);
 	if (!req)
@@ -972,6 +972,7 @@ u32 krb5_etm_checksum(struct crypto_sync_skcipher *cipher,
 	ahash_request_free(req);
 out_free_mem:
 	kfree(iv);
+out_free_checksum:
 	kfree_sensitive(checksumdata);
 	return err ? GSS_S_FAILURE : GSS_S_COMPLETE;
 }
--
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-02  9:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-31 13:56 [PATCH] sunrpc: Improve exception handling in krb5_etm_checksum() Markus Elfring
2024-01-01  2:18 ` Chuck Lever
2024-01-01 11:24   ` Markus Elfring
2024-01-01 16:55     ` Chuck Lever
2024-01-02  9:26       ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox