Skip to content

Commit

Permalink
ksmbd: fix kfree of uninitialized pointer oid
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Colin Ian King authored and namjaejeon committed Jun 18, 2021
1 parent 99f4525 commit 5fb6886
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/cifsd/asn1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 5fb6886

Please sign in to comment.