From: Namjae Jeon namjae.jeon@samsung.com
mainline inclusion from mainline-5.15-rc1 commit 73b8b08539423a888ed76b53401a6366e0e2af2b category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I60T7G CVE: NA
Reference: https://git.kernel.org/torvalds/linux/c/73b8b0853942
-------------------------------
Change success handling to failure handling in ksmbd_crypt_message().
Reviewed-by: Dan Carpenter dan.carpenter@oracle.com Signed-off-by: Namjae Jeon namjae.jeon@samsung.com Signed-off-by: Steve French stfrench@microsoft.com Signed-off-by: Jason Yan yanaijie@huawei.com Signed-off-by: Zhong Jinghua zhongjinghua@huawei.com --- fs/cifsd/auth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/cifsd/auth.c b/fs/cifsd/auth.c index 5a56dd65fa06..b0a9e4591fa5 100644 --- a/fs/cifsd/auth.c +++ b/fs/cifsd/auth.c @@ -1331,9 +1331,13 @@ int ksmbd_crypt_message(struct ksmbd_conn *conn, struct kvec *iov, rc = crypto_aead_encrypt(req); else rc = crypto_aead_decrypt(req); - if (!rc && enc) + if (rc) + goto free_iv; + + if (enc) memcpy(&tr_hdr->Signature, sign, SMB2_SIGNATURE_SIZE);
+free_iv: kfree(iv); free_sg: kfree(sg);