cifsd: fix memory leak when loop ends
authorMuhammad Usama Anjum <musamaanjum@gmail.com>
Thu, 1 Apr 2021 08:54:43 +0000 (17:54 +0900)
committerSteve French <stfrench@microsoft.com>
Tue, 11 May 2021 00:15:35 +0000 (19:15 -0500)
commitc250e8f5566f2e1a0ea177837520eff8e59c0b7d
treedd2bef477a5f807ab414d2982ab1599284677318
parent5da64d8784d36c0601743a5159a598f5888089c7
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: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1503590 ("Resource leaks")
Signed-off-by: Muhammad Usama Anjum <musamaanjum@gmail.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifsd/mgmt/share_config.c