Skip to content

Commit

Permalink
audit: do not call audit_getname on error
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eparis authored and Al Viro committed Jan 17, 2012
1 parent 633b454 commit 4043cde
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
28 changes: 13 additions & 15 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,19 @@ 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 = __getname();
int retval;

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);
Expand Down
3 changes: 0 additions & 3 deletions kernel/auditsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1913,9 +1913,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",
Expand Down

0 comments on commit 4043cde

Please sign in to comment.