diff mbox series

[04/15] checkpolicy: free ebitmap on error

Message ID 20240122135507.63506-4-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 8b115c45ad11
Delegated to: Petr Lautrbach
Headers show
Series [01/15] checkpolicy: add libfuzz based fuzzer | expand

Commit Message

Christian Göttsche Jan. 22, 2024, 1:54 p.m. UTC
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 checkpolicy/policy_define.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

James Carter Feb. 13, 2024, 8:35 p.m. UTC | #1
On Mon, Jan 22, 2024 at 9:02 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

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

> ---
>  checkpolicy/policy_define.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
> index db7e9d0e..053156df 100644
> --- a/checkpolicy/policy_define.c
> +++ b/checkpolicy/policy_define.c
> @@ -2544,6 +2544,8 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
>         int add = 1, ret = 0;
>         int suppress = 0;
>
> +       ebitmap_init(&tclasses);
> +
>         avrule = (avrule_t *) malloc(sizeof(avrule_t));
>         if (!avrule) {
>                 yyerror("memory error");
> @@ -2607,7 +2609,6 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
>                 }
>         }
>
> -       ebitmap_init(&tclasses);
>         ret = read_classes(&tclasses);
>         if (ret)
>                 goto out;
> @@ -2693,8 +2694,6 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
>                 free(id);
>         }
>
> -       ebitmap_destroy(&tclasses);
> -
>         avrule->perms = perms;
>         *rule = avrule;
>
> @@ -2703,6 +2702,9 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
>                 avrule_destroy(avrule);
>                 free(avrule);
>         }
> +
> +       ebitmap_destroy(&tclasses);
> +
>         return ret;
>
>  }
> --
> 2.43.0
>
>
James Carter March 4, 2024, 7:17 p.m. UTC | #2
On Tue, Feb 13, 2024 at 3:35 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Jan 22, 2024 at 9:02 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim

> > ---
> >  checkpolicy/policy_define.c | 8 +++++---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
> > index db7e9d0e..053156df 100644
> > --- a/checkpolicy/policy_define.c
> > +++ b/checkpolicy/policy_define.c
> > @@ -2544,6 +2544,8 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
> >         int add = 1, ret = 0;
> >         int suppress = 0;
> >
> > +       ebitmap_init(&tclasses);
> > +
> >         avrule = (avrule_t *) malloc(sizeof(avrule_t));
> >         if (!avrule) {
> >                 yyerror("memory error");
> > @@ -2607,7 +2609,6 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
> >                 }
> >         }
> >
> > -       ebitmap_init(&tclasses);
> >         ret = read_classes(&tclasses);
> >         if (ret)
> >                 goto out;
> > @@ -2693,8 +2694,6 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
> >                 free(id);
> >         }
> >
> > -       ebitmap_destroy(&tclasses);
> > -
> >         avrule->perms = perms;
> >         *rule = avrule;
> >
> > @@ -2703,6 +2702,9 @@ static int define_te_avtab_helper(int which, avrule_t ** rule)
> >                 avrule_destroy(avrule);
> >                 free(avrule);
> >         }
> > +
> > +       ebitmap_destroy(&tclasses);
> > +
> >         return ret;
> >
> >  }
> > --
> > 2.43.0
> >
> >
diff mbox series

Patch

diff --git a/checkpolicy/policy_define.c b/checkpolicy/policy_define.c
index db7e9d0e..053156df 100644
--- a/checkpolicy/policy_define.c
+++ b/checkpolicy/policy_define.c
@@ -2544,6 +2544,8 @@  static int define_te_avtab_helper(int which, avrule_t ** rule)
 	int add = 1, ret = 0;
 	int suppress = 0;
 
+	ebitmap_init(&tclasses);
+
 	avrule = (avrule_t *) malloc(sizeof(avrule_t));
 	if (!avrule) {
 		yyerror("memory error");
@@ -2607,7 +2609,6 @@  static int define_te_avtab_helper(int which, avrule_t ** rule)
 		}
 	}
 
-	ebitmap_init(&tclasses);
 	ret = read_classes(&tclasses);
 	if (ret)
 		goto out;
@@ -2693,8 +2694,6 @@  static int define_te_avtab_helper(int which, avrule_t ** rule)
 		free(id);
 	}
 
-	ebitmap_destroy(&tclasses);
-
 	avrule->perms = perms;
 	*rule = avrule;
 
@@ -2703,6 +2702,9 @@  static int define_te_avtab_helper(int which, avrule_t ** rule)
 		avrule_destroy(avrule);
 		free(avrule);
 	}
+
+	ebitmap_destroy(&tclasses);
+
 	return ret;
 
 }