[PATCH] acpiphp: turn off slot power at error case
[safe/jmp/linux-2.6] / fs / locks.c
index efad798..ab61a8b 100644 (file)
@@ -446,15 +446,14 @@ static struct lock_manager_operations lease_manager_ops = {
  */
 static int lease_init(struct file *filp, int type, struct file_lock *fl)
  {
+       if (assign_type(fl, type) != 0)
+               return -EINVAL;
+
        fl->fl_owner = current->files;
        fl->fl_pid = current->tgid;
 
        fl->fl_file = filp;
        fl->fl_flags = FL_LEASE;
-       if (assign_type(fl, type) != 0) {
-               locks_free_lock(fl);
-               return -EINVAL;
-       }
        fl->fl_start = 0;
        fl->fl_end = OFFSET_MAX;
        fl->fl_ops = NULL;
@@ -466,16 +465,19 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl)
 static int lease_alloc(struct file *filp, int type, struct file_lock **flp)
 {
        struct file_lock *fl = locks_alloc_lock();
-       int error;
+       int error = -ENOMEM;
 
        if (fl == NULL)
-               return -ENOMEM;
+               goto out;
 
        error = lease_init(filp, type, fl);
-       if (error)
-               return error;
+       if (error) {
+               locks_free_lock(fl);
+               fl = NULL;
+       }
+out:
        *flp = fl;
-       return 0;
+       return error;
 }
 
 /* Check if two locks overlap each other.
@@ -753,6 +755,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
        if (request->fl_type == F_UNLCK)
                goto out;
 
+       error = -ENOMEM;
        new_fl = locks_alloc_lock();
        if (new_fl == NULL)
                goto out;
@@ -779,6 +782,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
        locks_copy_lock(new_fl, request);
        locks_insert_lock(&inode->i_flock, new_fl);
        new_fl = NULL;
+       error = 0;
 
 out:
        unlock_kernel();
@@ -1372,6 +1376,7 @@ static int __setlease(struct file *filp, long arg, struct file_lock **flp)
                goto out;
 
        if (my_before != NULL) {
+               *flp = *my_before;
                error = lease->fl_lmops->fl_change(my_before, arg);
                goto out;
        }