[PATCH 23/26] audit: do not call audit_getname on error

Eric Paris
2011-11-17T22:04:53Z

Just a code cleanup really. We don't need to make a function call just for
it to return on error. This also makes the VFS function even easier to follow
and removes a conditional on a hot path.

Signed-off-by: Eric Paris <eparis@redhat.com>
---

fs/namei.c | 31 +++++++++++++++----------------
kernel/auditsc.c | 3 ---
2 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 0ba99d0..58c8d08 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -139,21 +139,20 @@ static int do_getname(const char __user *filename, char *page)

static char *getname_flags(const char __user *filename, int flags, int *empty)
{
- char *tmp, *result;
-
- result = ERR_PTR(-ENOMEM);
- tmp = __getname();
- if (tmp) {
- int retval = do_getname(filename, tmp);
-
- result = tmp;
- if (retval < 0) {
- if (retval == -ENOENT && empty)
- *empty = 1;
- if (retval != -ENOENT || !(flags & LOOKUP_EMPTY)) {
- __putname(tmp);
- result = ERR_PTR(retval);
- }
+ char *result;
+ int retval;
+
+ result = __getname();
+ if (!result)
+ return ERR_PTR(-ENOMEM);
+
+ retval = do_getname(filename, result);
+ if (retval < 0) {
+ if (retval == -ENOENT && empty)
+ *empty = 1;
+ if (retval != -ENOENT || !(flags & LOOKUP_EMPTY)) {
+ __putname(result);
+ return ERR_PTR(retval);
}
}
audit_getname(result);
@@ -162,7 +161,7 @@ static char *getname_flags(const char __user *filename, int flags, int *empty)

char *getname(const char __user * filename)
{
- return getname_flags(filename, 0, 0);
+ return getname_flags(filename, 0, NULL);
}

#ifdef CONFIG_AUDITSYSCALL
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 796dca6..fdcbc6b 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1975,9 +1975,6 @@ void __audit_getname(const char *name)
struct audit_context *context = current->audit_context;
struct audit_names *n;

- if (IS_ERR(name) || !name)
- return;
-
if (!context->in_syscall) {
#if AUDIT_DEBUG == 2
printk(KERN_ERR "%s:%d(:%d): ignoring getname(%p)\n",