ksmbd: fix unused err value in smb2_lock
authorNamjae Jeon <namjae.jeon@samsung.com>
Tue, 13 Jul 2021 08:17:28 +0000 (17:17 +0900)
committerNamjae Jeon <namjae.jeon@samsung.com>
Tue, 13 Jul 2021 08:22:49 +0000 (17:22 +0900)
CID 1502845 (#1 of 1): Unused value (UNUSED_VALUE)
value_overwrite: Overwriting previous write to err with value from
vfs_lock_file(filp, 0U, rlock, NULL).
6880                err = vfs_lock_file(filp, 0, rlock, NULL);
6881                if (err)
6882                        pr_err("rollback unlock fail : %d\n", err);

Reported-by: Coverity Scan <scan-admin@coverity.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/ksmbd/smb2pdu.c

index 319e07a..ee91d99 100644 (file)
@@ -6835,7 +6835,7 @@ skip:
        rsp->Reserved = 0;
        inc_rfc1001_len(rsp, 4);
        ksmbd_fd_put(work, fp);
-       return err;
+       return 0;
 
 out:
        list_for_each_entry_safe(smb_lock, tmp, &lock_list, llist) {
@@ -6846,15 +6846,16 @@ out:
 
        list_for_each_entry_safe(smb_lock, tmp, &rollback_list, llist) {
                struct file_lock *rlock = NULL;
+               int rc;
 
                rlock = smb_flock_init(filp);
                rlock->fl_type = F_UNLCK;
                rlock->fl_start = smb_lock->start;
                rlock->fl_end = smb_lock->end;
 
-               err = vfs_lock_file(filp, 0, rlock, NULL);
-               if (err)
-                       pr_err("rollback unlock fail : %d\n", err);
+               rc = vfs_lock_file(filp, 0, rlock, NULL);
+               if (rc)
+                       pr_err("rollback unlock fail : %d\n", rc);
 
                list_del(&smb_lock->llist);
                spin_lock(&work->conn->llist_lock);
@@ -6871,7 +6872,7 @@ out2:
        ksmbd_debug(SMB, "failed in taking lock(flags : %x)\n", flags);
        smb2_set_err_rsp(work);
        ksmbd_fd_put(work, fp);
-       return 0;
+       return err;
 }
 
 static int fsctl_copychunk(struct ksmbd_work *work, struct smb2_ioctl_req *req,