From: vbendel@redhat.com
To: paul@paul-moore.com, stephen.smalley.work@gmail.com,
eparis@parisplace.org
Cc: omosnace@redhat.com, selinux@vger.kernel.org,
linux-kernel@vger.kernel.org,
Vratislav Bendel <vbendel@redhat.com>
Subject: [PATCH 3/3] selinux: remove duplicate cond_list clean up calls
Date: Fri, 28 Jan 2022 21:28:58 +0100 [thread overview]
Message-ID: <20220128202858.96935-4-vbendel@redhat.com> (raw)
In-Reply-To: <20220128202858.96935-1-vbendel@redhat.com>
From: Vratislav Bendel <vbendel@redhat.com>
On error path from cond_read_list() and duplicate_policydb_cond_list()
the *_destroy() functions get called a second time in caller functions.
Remove the first calls and let the callers clean it.
Suggested-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Vratislav Bendel <vbendel@redhat.com>
---
security/selinux/ss/conditional.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c
index 8bc16ad3af9e..c333daaeceab 100644
--- a/security/selinux/ss/conditional.c
+++ b/security/selinux/ss/conditional.c
@@ -432,19 +432,16 @@ int cond_read_list(struct policydb *p, void *fp)
rc = avtab_alloc(&(p->te_cond_avtab), p->te_avtab.nel);
if (rc)
- goto err;
+ return rc;
p->cond_list_len = len;
for (i = 0; i < len; i++) {
rc = cond_read_node(p, &p->cond_list[i], fp);
if (rc)
- goto err;
+ return rc;
}
return 0;
-err:
- cond_list_destroy(p);
- return rc;
}
int cond_write_bool(void *vkey, void *datum, void *ptr)
@@ -643,7 +640,7 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
sizeof(*newp->cond_list),
GFP_KERNEL);
if (!newp->cond_list)
- goto error;
+ return -ENOMEM;
for (i = 0; i < origp->cond_list_len; i++) {
struct cond_node *newn = &newp->cond_list[i];
@@ -656,27 +653,22 @@ static int duplicate_policydb_cond_list(struct policydb *newp,
orign->expr.len * sizeof(*orign->expr.nodes),
GFP_KERNEL);
if (!newn->expr.nodes)
- goto error;
+ return -ENOMEM;
newn->expr.len = orign->expr.len;
rc = cond_dup_av_list(&newn->true_list, &orign->true_list,
&newp->te_cond_avtab);
if (rc)
- goto error;
+ return rc;
rc = cond_dup_av_list(&newn->false_list, &orign->false_list,
&newp->te_cond_avtab);
if (rc)
- goto error;
+ return rc;
}
return 0;
-
-error:
- avtab_destroy(&newp->te_cond_avtab);
- cond_list_destroy(newp);
- return -ENOMEM;
}
static int cond_bools_destroy(void *key, void *datum, void *args)
--
2.26.3
next prev parent reply other threads:[~2022-01-28 20:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 20:28 [PATCH 0/3] selinux: Fix and clean policydb->cond_list error paths vbendel
2022-01-28 20:28 ` [PATCH 1/3] selinux: consistently clear cond_list on " vbendel
2022-02-01 17:38 ` Paul Moore
2022-02-01 20:09 ` Paul Moore
2022-02-02 11:15 ` Vratislav Bendel
2022-01-28 20:28 ` [PATCH 2/3] selinux: fix double free of " vbendel
2022-01-28 20:28 ` vbendel [this message]
2022-02-01 20:09 ` [PATCH 3/3] selinux: remove duplicate cond_list clean up calls Paul Moore
2022-01-31 12:06 ` [PATCH 0/3] selinux: Fix and clean policydb->cond_list error paths Ondrej Mosnacek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220128202858.96935-4-vbendel@redhat.com \
--to=vbendel@redhat.com \
--cc=eparis@parisplace.org \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome