diff mbox series

[2/4] ksmbd-tools: Fix memory leak in lsarpc_lookup_names3_invoke

Message ID 20220301110006.4033351-2-mmakassikis@freebox.fr (mailing list archive)
State New, archived
Headers show
Series [1/4] ksmbd-tools: Fix function name typo | expand

Commit Message

Marios Makassikis March 1, 2022, 11 a.m. UTC
If usm_lookup_user() fails, the "ni" struct is leaked.

Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
---
 mountd/rpc_lsarpc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Hyunchul Lee March 1, 2022, 11:11 p.m. UTC | #1
Looks good to me.
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>

2022년 3월 1일 (화) 오후 10:58, Marios Makassikis <mmakassikis@freebox.fr>님이 작성:
>
> If usm_lookup_user() fails, the "ni" struct is leaked.
>
> Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr>
> ---
>  mountd/rpc_lsarpc.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mountd/rpc_lsarpc.c b/mountd/rpc_lsarpc.c
> index cc99a147b239..b9088950c46e 100644
> --- a/mountd/rpc_lsarpc.c
> +++ b/mountd/rpc_lsarpc.c
> @@ -357,8 +357,10 @@ static int lsarpc_lookup_names3_invoke(struct ksmbd_rpc_pipe *pipe)
>                 }
>
>                 ni->user = usm_lookup_user(name);
> -               if (!ni->user)
> +               if (!ni->user) {
> +                       free(ni);
>                         break;
> +               }
>                 pipe->entries = g_array_append_val(pipe->entries, ni);
>                 pipe->num_entries++;
>                 smb_init_domain_sid(&ni->sid);
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/mountd/rpc_lsarpc.c b/mountd/rpc_lsarpc.c
index cc99a147b239..b9088950c46e 100644
--- a/mountd/rpc_lsarpc.c
+++ b/mountd/rpc_lsarpc.c
@@ -357,8 +357,10 @@  static int lsarpc_lookup_names3_invoke(struct ksmbd_rpc_pipe *pipe)
 		}
 
 		ni->user = usm_lookup_user(name);
-		if (!ni->user)
+		if (!ni->user) {
+			free(ni);
 			break;
+		}
 		pipe->entries = g_array_append_val(pipe->entries, ni);
 		pipe->num_entries++;
 		smb_init_domain_sid(&ni->sid);