Commit 5fb68864 authored by Colin Ian King's avatar Colin Ian King Committed by Namjae Jeon

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: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 99f45259
...@@ -66,7 +66,7 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen, ...@@ -66,7 +66,7 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen,
vlen += 1; vlen += 1;
if (vlen < 2 || vlen > UINT_MAX / sizeof(unsigned long)) if (vlen < 2 || vlen > UINT_MAX / sizeof(unsigned long))
return false; goto fail_nullify;
*oid = kmalloc(vlen * sizeof(unsigned long), GFP_KERNEL); *oid = kmalloc(vlen * sizeof(unsigned long), GFP_KERNEL);
if (!*oid) if (!*oid)
...@@ -102,6 +102,7 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen, ...@@ -102,6 +102,7 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen,
fail: fail:
kfree(*oid); kfree(*oid);
fail_nullify:
*oid = NULL; *oid = NULL;
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment