From: Namjae Jeon namjae.jeon@samsung.com
mainline inclusion from mainline-5.15-rc1 commit cdd10398e71a1843ef99ed545bbb872b6cb9d249 category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I60T7G CVE: NA
Reference: https://git.kernel.org/torvalds/linux/c/cdd10398e71a
-------------------------------
Add goto fail in asn1_oid_decode() to clean-up exception handling code.
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/asn1.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
diff --git a/fs/cifsd/asn1.c b/fs/cifsd/asn1.c index aa6ea855c422..f2628dc3490f 100644 --- a/fs/cifsd/asn1.c +++ b/fs/cifsd/asn1.c @@ -74,11 +74,8 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen,
optr = *oid;
- if (!asn1_subid_decode(&iptr, end, &subid)) { - kfree(*oid); - *oid = NULL; - return false; - } + if (!asn1_subid_decode(&iptr, end, &subid)) + goto fail;
if (subid < 40) { optr[0] = 0; @@ -95,19 +92,18 @@ static bool asn1_oid_decode(const unsigned char *value, size_t vlen, optr += 2;
while (iptr < end) { - if (++(*oidlen) > vlen) { - kfree(*oid); - *oid = NULL; - return false; - } + if (++(*oidlen) > vlen) + goto fail;
- if (!asn1_subid_decode(&iptr, end, optr++)) { - kfree(*oid); - *oid = NULL; - return false; - } + if (!asn1_subid_decode(&iptr, end, optr++)) + goto fail; } return true; + +fail: + kfree(*oid); + *oid = NULL; + return false; }
static bool