Commit c250e8f5 authored by Muhammad Usama Anjum's avatar Muhammad Usama Anjum Committed by Steve French

cifsd: fix memory leak when loop ends

Memory is being allocated and if veto_list is zero, the loop breaks
without cleaning up the allocated memory. In this patch, the length
check has been moved before allocation. If loop breaks, the memory isn't
allocated in the first place. Thus the memory is being protected from
leaking.
Reported-by: default avatarcoverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1503590 ("Resource leaks")
Signed-off-by: default avatarMuhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 5da64d87
...@@ -92,14 +92,14 @@ static int parse_veto_list(struct ksmbd_share_config *share, ...@@ -92,14 +92,14 @@ static int parse_veto_list(struct ksmbd_share_config *share,
while (veto_list_sz > 0) { while (veto_list_sz > 0) {
struct ksmbd_veto_pattern *p; struct ksmbd_veto_pattern *p;
p = kzalloc(sizeof(struct ksmbd_veto_pattern), GFP_KERNEL);
if (!p)
return -ENOMEM;
sz = strlen(veto_list); sz = strlen(veto_list);
if (!sz) if (!sz)
break; break;
p = kzalloc(sizeof(struct ksmbd_veto_pattern), GFP_KERNEL);
if (!p)
return -ENOMEM;
p->pattern = kstrdup(veto_list, GFP_KERNEL); p->pattern = kstrdup(veto_list, GFP_KERNEL);
if (!p->pattern) { if (!p->pattern) {
ksmbd_free(p); ksmbd_free(p);
......
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