diff mbox series

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

Message ID Zd1QhmIB/SzPDoDf@dread.disaster.area (mailing list archive)
State New
Headers show
Series None | expand

Commit Message

Dave Chinner Feb. 27, 2024, 3:01 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>
---

Version 2:
- also fix kfree() in xlog_cil_process_intents().
- checked that kvfree() is used for all lip->li_lv_shadow freeing
  calls.

 fs/xfs/xfs_log_cil.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Darrick J. Wong Feb. 27, 2024, 4:25 a.m. UTC | #1
On Tue, Feb 27, 2024 at 02:01:26PM +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>

Looks good to me, will run this one through fstestsclod overnight...
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
> 
> Version 2:
> - also fix kfree() in xlog_cil_process_intents().
> - checked that kvfree() is used for all lip->li_lv_shadow freeing
>   calls.
> 
>  fs/xfs/xfs_log_cil.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> index f15735d0296a..4d52854bcb29 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);
>  	}
>  }
>  
> @@ -1717,7 +1717,7 @@ xlog_cil_process_intents(
>  		set_bit(XFS_LI_WHITEOUT, &ilip->li_flags);
>  		trace_xfs_cil_whiteout_mark(ilip);
>  		len += ilip->li_lv->lv_bytes;
> -		kfree(ilip->li_lv);
> +		kvfree(ilip->li_lv);
>  		ilip->li_lv = NULL;
>  
>  		xfs_trans_del_item(lip);
>
Chandan Babu R Feb. 27, 2024, 8:45 a.m. UTC | #2
On Tue, Feb 27, 2024 at 02:01:26 PM +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>

I have changed the Reported-by tag value to Darrick (since he reported it
first) when applying the patches to my local Git tree.
Christoph Hellwig Feb. 27, 2024, 2:48 p.m. UTC | #3
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong Feb. 28, 2024, 2:31 a.m. UTC | #4
On Mon, Feb 26, 2024 at 08:25:37PM -0800, Darrick J. Wong wrote:
> On Tue, Feb 27, 2024 at 02:01:26PM +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>
> 
> Looks good to me, will run this one through fstestsclod overnight...
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>

FWIW I didn't see any further crashes after applying this patch, so:
Tested-by: Darrick J. Wong <djwong@kernel.org>

--D

> --D
> 
> > ---
> > 
> > Version 2:
> > - also fix kfree() in xlog_cil_process_intents().
> > - checked that kvfree() is used for all lip->li_lv_shadow freeing
> >   calls.
> > 
> >  fs/xfs/xfs_log_cil.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
> > index f15735d0296a..4d52854bcb29 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);
> >  	}
> >  }
> >  
> > @@ -1717,7 +1717,7 @@ xlog_cil_process_intents(
> >  		set_bit(XFS_LI_WHITEOUT, &ilip->li_flags);
> >  		trace_xfs_cil_whiteout_mark(ilip);
> >  		len += ilip->li_lv->lv_bytes;
> > -		kfree(ilip->li_lv);
> > +		kvfree(ilip->li_lv);
> >  		ilip->li_lv = NULL;
> >  
> >  		xfs_trans_del_item(lip);
> > 
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index f15735d0296a..4d52854bcb29 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);
 	}
 }
 
@@ -1717,7 +1717,7 @@  xlog_cil_process_intents(
 		set_bit(XFS_LI_WHITEOUT, &ilip->li_flags);
 		trace_xfs_cil_whiteout_mark(ilip);
 		len += ilip->li_lv->lv_bytes;
-		kfree(ilip->li_lv);
+		kvfree(ilip->li_lv);
 		ilip->li_lv = NULL;
 
 		xfs_trans_del_item(lip);