public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ocfs2: fix double free in user_cluster_connect()
@ 2025-09-23 11:26 Dan Carpenter
  2025-09-23 12:08 ` Joseph Qi
  2025-09-23 12:52 ` Goldwyn Rodrigues
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-09-23 11:26 UTC (permalink / raw)
  To: Goldwyn Rodrigues
  Cc: Mark Fasheh, Joel Becker, Joseph Qi, Andrew Morton, ocfs2-devel,
	linux-kernel, kernel-janitors

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")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/ocfs2/stack_user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
index 765105f1ff8a..be0a5758bd40 100644
--- a/fs/ocfs2/stack_user.c
+++ b/fs/ocfs2/stack_user.c
@@ -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));
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ocfs2: fix double free in user_cluster_connect()
  2025-09-23 11:26 [PATCH] ocfs2: fix double free in user_cluster_connect() Dan Carpenter
@ 2025-09-23 12:08 ` Joseph Qi
  2025-09-23 12:52 ` Goldwyn Rodrigues
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Qi @ 2025-09-23 12:08 UTC (permalink / raw)
  To: Dan Carpenter, Goldwyn Rodrigues, Andrew Morton
  Cc: Mark Fasheh, Joel Becker, ocfs2-devel, linux-kernel,
	kernel-janitors



On 2025/9/23 19:26, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Looks fine.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/stack_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c
> index 765105f1ff8a..be0a5758bd40 100644
> --- a/fs/ocfs2/stack_user.c
> +++ b/fs/ocfs2/stack_user.c
> @@ -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));


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ocfs2: fix double free in user_cluster_connect()
  2025-09-23 11:26 [PATCH] ocfs2: fix double free in user_cluster_connect() Dan Carpenter
  2025-09-23 12:08 ` Joseph Qi
@ 2025-09-23 12:52 ` Goldwyn Rodrigues
  1 sibling, 0 replies; 3+ messages in thread
From: Goldwyn Rodrigues @ 2025-09-23 12:52 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mark Fasheh, Joel Becker, Joseph Qi, Andrew Morton, ocfs2-devel,
	linux-kernel, kernel-janitors

On 14:26 23/09, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Looks good. Thanks!

Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.de>

-- 
Goldwyn

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-23 12:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 11:26 [PATCH] ocfs2: fix double free in user_cluster_connect() Dan Carpenter
2025-09-23 12:08 ` Joseph Qi
2025-09-23 12:52 ` Goldwyn Rodrigues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox