@@ -1605,6 +1605,7 @@ int smb_locking_andx(struct ksmbd_work *work)
16051605 if (!(filp -> f_mode & FMODE_READ )) {
16061606 rsp -> hdr .Status .CifsError =
16071607 STATUS_ACCESS_DENIED ;
1608+ locks_free_lock (flock );
16081609 goto out ;
16091610 }
16101611 cmd = F_SETLKW ;
@@ -1614,6 +1615,7 @@ int smb_locking_andx(struct ksmbd_work *work)
16141615 if (!(filp -> f_mode & FMODE_WRITE )) {
16151616 rsp -> hdr .Status .CifsError =
16161617 STATUS_ACCESS_DENIED ;
1618+ locks_free_lock (flock );
16171619 goto out ;
16181620 }
16191621 cmd = F_SETLKW ;
@@ -1639,15 +1641,15 @@ int smb_locking_andx(struct ksmbd_work *work)
16391641
16401642 if (offset > loff_max ) {
16411643 pr_err ("Invalid lock range requested\n" );
1642- rsp -> hdr .Status .CifsError =
1643- STATUS_INVALID_LOCK_RANGE ;
1644+ rsp -> hdr .Status .CifsError = STATUS_INVALID_LOCK_RANGE ;
1645+ locks_free_lock ( flock ) ;
16441646 goto out ;
16451647 }
16461648
16471649 if (offset > 0 && length > (loff_max - offset ) + 1 ) {
16481650 pr_err ("Invalid lock range requested\n" );
1649- rsp -> hdr .Status .CifsError =
1650- STATUS_INVALID_LOCK_RANGE ;
1651+ rsp -> hdr .Status .CifsError = STATUS_INVALID_LOCK_RANGE ;
1652+ locks_free_lock ( flock ) ;
16511653 goto out ;
16521654 }
16531655
@@ -1665,8 +1667,10 @@ int smb_locking_andx(struct ksmbd_work *work)
16651667
16661668 smb_lock = smb_lock_init (flock , cmd , req -> LockType , offset ,
16671669 length , & lock_list );
1668- if (!smb_lock )
1670+ if (!smb_lock ) {
1671+ locks_free_lock (flock );
16691672 goto out ;
1673+ }
16701674 }
16711675
16721676 list_for_each_entry_safe (smb_lock , tmp , & lock_list , llist ) {
@@ -1884,6 +1888,7 @@ int smb_locking_andx(struct ksmbd_work *work)
18841888 fp -> cflock_cnt = 0 ;
18851889 } else if (err == - ENOENT ) {
18861890 rsp -> hdr .Status .CifsError = STATUS_RANGE_NOT_LOCKED ;
1891+ locks_free_lock (flock );
18871892 goto out ;
18881893 }
18891894 locks_free_lock (flock );
0 commit comments