]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] proper error cleanup on security_acct hook
authorChris Wright <chrisw@osdl.org>
Mon, 8 Mar 2004 04:29:33 +0000 (20:29 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 8 Mar 2004 04:29:33 +0000 (20:29 -0800)
Noted by Stephen Smalley: sys_acct does not properly clean up the open
file when the security_acct hook returns an error.

Fixed thus.

kernel/acct.c

index a679f4bb9854291a311cd1a23c64186513656e81..cf50df59177a310d14cea421b804a420db7fa7a3 100644 (file)
@@ -235,8 +235,11 @@ asmlinkage long sys_acct(const char *name)
        }
 
        error = security_acct(file);
-       if (error)
+       if (error) {
+               if (file)
+                       filp_close(file, NULL);
                return error;
+       }
 
        spin_lock(&acct_globals.lock);
        acct_file_reopen(file);