]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ocfs2: fix double free in user_cluster_connect()
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 23 Sep 2025 11:26:07 +0000 (14:26 +0300)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 28 Sep 2025 18:36:13 +0000 (11:36 -0700)
user_cluster_disconnect() 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.

Link: https://lkml.kernel.org/r/aNKDz_7JF7aycZ0k@stanley.mountain
Fixes: c994c2ebdbbc ("ocfs2: use the new DLM operation callbacks while requesting new lockspace")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.de>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ocfs2/stack_user.c

index 0f045e45fa0c3e6a7cc9ca0a756e1fc79bafdaae..439742cec3c26288b95ce09b506996786bbca461 100644 (file)
@@ -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));