Skip to content

Commit 5be998a

Browse files
author
Al Viro
committed
ipe: don't bother with removal of files in directory we'll be removing
... and use securityfs_remove() instead of securityfs_recursive_remove() Acked-by: Fan Wu <wufan@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e25fc55 commit 5be998a

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

security/ipe/fs.c

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,8 @@
1212
#include "policy.h"
1313
#include "audit.h"
1414

15-
static struct dentry *np __ro_after_init;
1615
static struct dentry *root __ro_after_init;
1716
struct dentry *policy_root __ro_after_init;
18-
static struct dentry *audit_node __ro_after_init;
19-
static struct dentry *enforce_node __ro_after_init;
2017

2118
/**
2219
* setaudit() - Write handler for the securityfs node, "ipe/success_audit"
@@ -200,27 +197,26 @@ static int __init ipe_init_securityfs(void)
200197
{
201198
int rc = 0;
202199
struct ipe_policy *ap;
200+
struct dentry *dentry;
203201

204202
if (!ipe_enabled)
205203
return -EOPNOTSUPP;
206204

207205
root = securityfs_create_dir("ipe", NULL);
208-
if (IS_ERR(root)) {
209-
rc = PTR_ERR(root);
210-
goto err;
211-
}
206+
if (IS_ERR(root))
207+
return PTR_ERR(root);
212208

213-
audit_node = securityfs_create_file("success_audit", 0600, root,
209+
dentry = securityfs_create_file("success_audit", 0600, root,
214210
NULL, &audit_fops);
215-
if (IS_ERR(audit_node)) {
216-
rc = PTR_ERR(audit_node);
211+
if (IS_ERR(dentry)) {
212+
rc = PTR_ERR(dentry);
217213
goto err;
218214
}
219215

220-
enforce_node = securityfs_create_file("enforce", 0600, root, NULL,
216+
dentry = securityfs_create_file("enforce", 0600, root, NULL,
221217
&enforce_fops);
222-
if (IS_ERR(enforce_node)) {
223-
rc = PTR_ERR(enforce_node);
218+
if (IS_ERR(dentry)) {
219+
rc = PTR_ERR(dentry);
224220
goto err;
225221
}
226222

@@ -237,18 +233,14 @@ static int __init ipe_init_securityfs(void)
237233
goto err;
238234
}
239235

240-
np = securityfs_create_file("new_policy", 0200, root, NULL, &np_fops);
241-
if (IS_ERR(np)) {
242-
rc = PTR_ERR(np);
236+
dentry = securityfs_create_file("new_policy", 0200, root, NULL, &np_fops);
237+
if (IS_ERR(dentry)) {
238+
rc = PTR_ERR(dentry);
243239
goto err;
244240
}
245241

246242
return 0;
247243
err:
248-
securityfs_remove(np);
249-
securityfs_remove(policy_root);
250-
securityfs_remove(enforce_node);
251-
securityfs_remove(audit_node);
252244
securityfs_remove(root);
253245
return rc;
254246
}

security/ipe/policy_fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static const struct ipefs_file policy_subdir[] = {
438438
*/
439439
void ipe_del_policyfs_node(struct ipe_policy *p)
440440
{
441-
securityfs_recursive_remove(p->policyfs);
441+
securityfs_remove(p->policyfs);
442442
p->policyfs = NULL;
443443
}
444444

@@ -485,6 +485,6 @@ int ipe_new_policyfs_node(struct ipe_policy *p)
485485

486486
return 0;
487487
err:
488-
securityfs_recursive_remove(policyfs);
488+
securityfs_remove(policyfs);
489489
return rc;
490490
}

0 commit comments

Comments
 (0)