All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libselinux: free memory in error branch
@ 2022-05-10 17:45 Christian Göttsche
  2022-05-11 20:42 ` James Carter
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Göttsche @ 2022-05-10 17:45 UTC (permalink / raw)
  To: selinux

In case the allocation for the filename fails, free the memory of the context.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/src/selinux_restorecon.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index e6192912..e160c06e 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -489,13 +489,15 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
 		goto oom_freefl;
 	fl->file = strdup(file);
 	if (!fl->file)
-		goto oom_freefl;
+		goto oom_freeflcon;
 	fl->next = prevfl->next;
 	prevfl->next = fl;
 
 	__pthread_mutex_unlock(&fl_mutex);
 	return 0;
 
+oom_freeflcon:
+	free(fl->con);
 oom_freefl:
 	free(fl);
 oom:
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libselinux: free memory in error branch
  2022-05-10 17:45 [PATCH] libselinux: free memory in error branch Christian Göttsche
@ 2022-05-11 20:42 ` James Carter
  2022-05-16 17:13   ` James Carter
  0 siblings, 1 reply; 3+ messages in thread
From: James Carter @ 2022-05-11 20:42 UTC (permalink / raw)
  To: Christian Göttsche; +Cc: SElinux list

On Tue, May 10, 2022 at 5:02 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> In case the allocation for the filename fails, free the memory of the context.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libselinux/src/selinux_restorecon.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
> index e6192912..e160c06e 100644
> --- a/libselinux/src/selinux_restorecon.c
> +++ b/libselinux/src/selinux_restorecon.c
> @@ -489,13 +489,15 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
>                 goto oom_freefl;
>         fl->file = strdup(file);
>         if (!fl->file)
> -               goto oom_freefl;
> +               goto oom_freeflcon;
>         fl->next = prevfl->next;
>         prevfl->next = fl;
>
>         __pthread_mutex_unlock(&fl_mutex);
>         return 0;
>
> +oom_freeflcon:
> +       free(fl->con);
>  oom_freefl:
>         free(fl);
>  oom:
> --
> 2.36.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libselinux: free memory in error branch
  2022-05-11 20:42 ` James Carter
@ 2022-05-16 17:13   ` James Carter
  0 siblings, 0 replies; 3+ messages in thread
From: James Carter @ 2022-05-16 17:13 UTC (permalink / raw)
  To: Christian Göttsche; +Cc: SElinux list

On Wed, May 11, 2022 at 4:42 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Tue, May 10, 2022 at 5:02 PM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > In case the allocation for the filename fails, free the memory of the context.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>

Merged.
Thanks,
Jim

> > ---
> >  libselinux/src/selinux_restorecon.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
> > index e6192912..e160c06e 100644
> > --- a/libselinux/src/selinux_restorecon.c
> > +++ b/libselinux/src/selinux_restorecon.c
> > @@ -489,13 +489,15 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
> >                 goto oom_freefl;
> >         fl->file = strdup(file);
> >         if (!fl->file)
> > -               goto oom_freefl;
> > +               goto oom_freeflcon;
> >         fl->next = prevfl->next;
> >         prevfl->next = fl;
> >
> >         __pthread_mutex_unlock(&fl_mutex);
> >         return 0;
> >
> > +oom_freeflcon:
> > +       free(fl->con);
> >  oom_freefl:
> >         free(fl);
> >  oom:
> > --
> > 2.36.1
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-16 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-10 17:45 [PATCH] libselinux: free memory in error branch Christian Göttsche
2022-05-11 20:42 ` James Carter
2022-05-16 17:13   ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.