if (lock_start > U64_MAX - lock_length) {
                        pr_err("Invalid lock range requested\n");
                        rsp->hdr.Status = STATUS_INVALID_LOCK_RANGE;
+                       locks_free_lock(flock);
                        goto out;
                }
 
                                    "the end offset(%llx) is smaller than the start offset(%llx)\n",
                                    flock->fl_end, flock->fl_start);
                        rsp->hdr.Status = STATUS_INVALID_LOCK_RANGE;
+                       locks_free_lock(flock);
                        goto out;
                }
 
                                    flock->fl_type != F_UNLCK) {
                                        pr_err("conflict two locks in one request\n");
                                        err = -EINVAL;
+                                       locks_free_lock(flock);
                                        goto out;
                                }
                        }
                smb_lock = smb2_lock_init(flock, cmd, flags, &lock_list);
                if (!smb_lock) {
                        err = -EINVAL;
+                       locks_free_lock(flock);
                        goto out;
                }
        }