[PATCH v2 3/3] md-cluster: fix ack_lockres leak in __sendmsg error path

[email protected]
Newsgroups gmane.linux.kernel.stable,gmane.linux.raid,gmane.linux.kernel
Message-ID <[email protected]>
From: Cao Guanghui <[email protected]>

In __sendmsg(), if the down-conversion of ack_lockres from EX to CR
fails (step 5), the code jumps to failed_ack which only unlocks
message_lockres.  The ack_lockres is left in EX state, causing a
cluster-wide deadlock as other nodes cannot acquire the ack lock.

Restore ack_lockres to CR in the failed_ack path when an error occurred,
so the lock is not leaked in EX state.

Fixes: 601b515c5dcc ("Communication Framework: Sending functions")
Cc: [email protected]
Signed-off-by: Cao Guanghui <[email protected]>
---
 drivers/md/md-cluster.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -801,8 +801,10 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
 	}
 
 failed_ack:
+	if (error)
+		dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR);
 	while ((unlock_error = dlm_unlock_sync(cinfo->message_lockres)))
 		pr_err("md-cluster: failed convert to NL on MESSAGE(%d)\n",
 			unlock_error);
 
 	return error;
-- 
2.34.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.