summaryrefslogtreecommitdiffstats
path: root/fs/cifsd/asn1.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-06-18 02:54:53 +0200
committerNamjae Jeon <namjae.jeon@samsung.com>2021-06-19 01:34:19 +0200
commit5fb68864674faa3e0a4fc767c4a87f51ece218c6 (patch)
tree4815c84818802d5e426b925dc3b14b65321375a3 /fs/cifsd/asn1.c
parentcifsd: append ksmbd prefix into names for asn1 decoder (diff)
downloadlinux-5fb68864674faa3e0a4fc767c4a87f51ece218c6.tar.xz
linux-5fb68864674faa3e0a4fc767c4a87f51ece218c6.zip
ksmbd: fix kfree of uninitialized pointer oid
Currently function ksmbd_neg_token_init_mech_type can kfree an uninitialized pointer oid when the call to asn1_oid_decode fails when vlen is out of range. All the other failure cases in function asn1_oid_decode set *oid to NULL on an error, so fix the issue by ensuring the vlen out of range error also nullifies the pointer. Addresses-Coverity: ("Uninitialized pointer read") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to '')
-rw-r--r--fs/cifsd/asn1.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/cifsd/asn1.c b/fs/cifsd/asn1.c
index 2c63a3e5618b..b014f4638610 100644
--- a/fs/cifsd/asn1.c
+++ b/fs/cifsd/asn1.c
@@ -66,7 +66,7 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen,
vlen += 1;
if (vlen < 2 || vlen > UINT_MAX / sizeof(unsigned long))
- return false;
+ goto fail_nullify;
*oid = kmalloc(vlen * sizeof(unsigned long), GFP_KERNEL);
if (!*oid)
@@ -102,6 +102,7 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen,
fail:
kfree(*oid);
+fail_nullify:
*oid = NULL;
return false;
}