diff mbox series

[2/2] xfs: use kvfree() in xlog_cil_free_logvec()

Message ID 20240227001135.718165-3-david@fromorbit.com (mailing list archive)
State Superseded, archived
Headers show
Series xfs: kmalloc/kfree conversion fixes | expand

Commit Message

Dave Chinner Feb. 27, 2024, 12:05 a.m. UTC
From: Dave Chinner <dchinner@redhat.com>

The xfs_log_vec items are allocated by xlog_kvmalloc(), and so need
to be freed with kvfree. This was missed when coverting from the
kmem_free() API.

Reported-by: Chandan Babu R <chandanbabu@kernel.org>
Fixes: 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_log_cil.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong Feb. 27, 2024, 12:46 a.m. UTC | #1
On Tue, Feb 27, 2024 at 11:05:32AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> The xfs_log_vec items are allocated by xlog_kvmalloc(), and so need
> to be freed with kvfree. This was missed when coverting from the
> kmem_free() API.
> 
> Reported-by: Chandan Babu R <chandanbabu@kernel.org>
> Fixes: 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  fs/xfs/xfs_log_cil.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index f15735d0296a..9544ddaef066 100644
> --- a/fs/xfs/xfs_log_cil.c
> +++ b/fs/xfs/xfs_log_cil.c
> @@ -877,7 +877,7 @@ xlog_cil_free_logvec(
>  	while (!list_empty(lv_chain)) {
>  		lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);
>  		list_del_init(&lv->lv_list);
> -		kfree(lv);
> +		kvfree(lv);

Is it necessary to s/kfree/kvfree/ in xlog_cil_process_intents when we
free the xfs_log_vec that's attached to a xfs_log_item?

--D

>  	}
>  }
>  
> -- 
> 2.43.0
> 
>
Dave Chinner Feb. 27, 2024, 2:37 a.m. UTC | #2
On Mon, Feb 26, 2024 at 04:46:21PM -0800, Darrick J. Wong wrote:
> On Tue, Feb 27, 2024 at 11:05:32AM +1100, Dave Chinner wrote:
> > From: Dave Chinner <dchinner@redhat.com>
> > 
> > The xfs_log_vec items are allocated by xlog_kvmalloc(), and so need
> > to be freed with kvfree. This was missed when coverting from the
> > kmem_free() API.
> > 
> > Reported-by: Chandan Babu R <chandanbabu@kernel.org>
> > Fixes: 49292576136f ("xfs: convert kmem_free() for kvmalloc users to kvfree()")
> > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> > ---
> >  fs/xfs/xfs_log_cil.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> > index f15735d0296a..9544ddaef066 100644
> > --- a/fs/xfs/xfs_log_cil.c
> > +++ b/fs/xfs/xfs_log_cil.c
> > @@ -877,7 +877,7 @@ xlog_cil_free_logvec(
> >  	while (!list_empty(lv_chain)) {
> >  		lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);
> >  		list_del_init(&lv->lv_list);
> > -		kfree(lv);
> > +		kvfree(lv);
> 
> Is it necessary to s/kfree/kvfree/ in xlog_cil_process_intents when we
> free the xfs_log_vec that's attached to a xfs_log_item?

Yes, it should, even though intents are pretty much
guaranteed to be small enough they will never use vmalloc.

Good catch.

-Dave.
diff mbox series

Patch

diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index f15735d0296a..9544ddaef066 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -877,7 +877,7 @@  xlog_cil_free_logvec(
 	while (!list_empty(lv_chain)) {
 		lv = list_first_entry(lv_chain, struct xfs_log_vec, lv_list);
 		list_del_init(&lv->lv_list);
-		kfree(lv);
+		kvfree(lv);
 	}
 }