Skip to contentSkip to conversation

ocfs2: fix double free in user_cluster_connect()

PATCH Applied Dan Carpenter 3 participants 3 messages Sep 23, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ocfs2: fix double free in user_cluster_connect()

The user_cluster_disconnect() function frees "conn->cc_private" which is "lc" but then the error handling frees "lc" a second time. Set "lc" to NULL on this path to avoid a double free.

Fixes c994c2ebdbbc ("ocfs2: use the new DLM operation callbacks while requesting new lockspace")
---
 fs/ocfs2/stack_user.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/stack_user.c +1 -0
index 765105f1ff8a..be0a5758bd40 100644
@@ -1011,6 +1011,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 			printk(KERN_ERR "ocfs2: Could not determine"
 					" locking version\n");
 			user_cluster_disconnect(conn);
+			lc = NULL;
 			goto out;
 		}
 		wait_event(lc->oc_wait, (atomic_read(&lc->oc_this_node) > 0));
Signature · 1 line
2.51.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The user_cluster_disconnect() function frees "conn->cc_private" which is "lc" but then the error handling frees "lc" a second time. Set "lc" to NULL on this path to avoid a double free.

Fixes c994c2ebdbbc ("ocfs2: use the new DLM operation callbacks while requesting new lockspace")

Looks fine.

Quoted 16 lines
---
 fs/ocfs2/stack_user.c | 1 +
 1 file changed, 1 insertion(+)
fs/ocfs2/stack_user.c +1 -0
index 765105f1ff8a..be0a5758bd40 100644
@@ -1011,6 +1011,7 @@ static int user_cluster_connect(struct ocfs2_cluster_connection *conn)
 			printk(KERN_ERR "ocfs2: Could not determine"
 					" locking version\n");
 			user_cluster_disconnect(conn);
+			lc = NULL;
 			goto out;
 		}
 		wait_event(lc->oc_wait, (atomic_read(&lc->oc_this_node) > 0));
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 6 lines · Dan Carpenter

The user_cluster_disconnect() function frees "conn->cc_private" which is "lc" but then the error handling frees "lc" a second time. Set "lc" to NULL on this path to avoid a double free.

Fixes c994c2ebdbbc ("ocfs2: use the new DLM operation callbacks while requesting new lockspace")

Looks good. Thanks!

Signature · 1 line
Goldwyn