]> git.baikalelectronics.ru Git - kernel.git/commitdiff
cifs: release lock earlier in dequeue_mid error case
authorSteve French <stfrench@microsoft.com>
Fri, 12 Nov 2021 15:55:03 +0000 (09:55 -0600)
committerSteve French <stfrench@microsoft.com>
Fri, 12 Nov 2021 18:59:51 +0000 (12:59 -0600)
In dequeue_mid we can log an error while holding a spinlock,
GlobalMid_Lock.  Coverity notes that the error logging
also grabs a lock so it is cleaner (and a bit safer) to
release the GlobalMid_Lock before logging the warning.

Addresses-Coverity: 1507573 ("Thread deadlock")
Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/connect.c

index df33659586037b933e16eb0b967d6f1d63ce8d56..ae21dff02f30a4bdce31fd528c3aeae479958904 100644 (file)
@@ -709,13 +709,14 @@ dequeue_mid(struct mid_q_entry *mid, bool malformed)
         * Trying to handle/dequeue a mid after the send_recv()
         * function has finished processing it is a bug.
         */
-       if (mid->mid_flags & MID_DELETED)
+       if (mid->mid_flags & MID_DELETED) {
+               spin_unlock(&GlobalMid_Lock);
                pr_warn_once("trying to dequeue a deleted mid\n");
-       else {
+       else {
                list_del_init(&mid->qhead);
                mid->mid_flags |= MID_DELETED;
+               spin_unlock(&GlobalMid_Lock);
        }
-       spin_unlock(&GlobalMid_Lock);
 }
 
 static unsigned int