mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Zilin Guan <zilin@seu.edu.cn>
Cc: brett.creeley@amd.com, jgg@ziepe.ca, yishaih@nvidia.com,
	shameerali.kolothum.thodi@huawei.com, kevin.tian@intel.com,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	jianhao.xu@seu.edu.cn
Subject: Re: [PATCH] vfio/pds: replace bitmap_free with vfree
Date: Sat, 13 Sep 2025 09:02:50 +0100	[thread overview]
Message-ID: <20250913090250.0cde9ca3.alex.williamson@redhat.com> (raw)
In-Reply-To: <20250912150418.129306-1-zilin@seu.edu.cn>

On Fri, 12 Sep 2025 15:04:18 +0000
Zilin Guan <zilin@seu.edu.cn> wrote:

> host_ack_bmp is allocated with vzalloc but is currently freed via
> bitmap_free (which ends up using kfree).  This is incorrect as
> allocation and deallocation functions should be paired.

This patch is fixing the freeing of host_seq_bmp, not host_ack_bmp.
Both are allocated with vzalloc().  The same logic applies but the
commit log is incorrect.
 
> Using mismatched alloc/free may lead to undefined behavior, memory leaks,
> or system instability.
> 
> This patch fixes the mismatch by freeing host_ack_bmp with vfree to
> match the vzalloc allocation.
> 

Fixes: f232836a9152 ("vfio/pds: Add support for dirty page tracking")

Thanks,
Alex

> Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
> ---
>  drivers/vfio/pci/pds/dirty.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/pci/pds/dirty.c b/drivers/vfio/pci/pds/dirty.c
> index c51f5e4c3dd6..481992142f79 100644
> --- a/drivers/vfio/pci/pds/dirty.c
> +++ b/drivers/vfio/pci/pds/dirty.c
> @@ -82,7 +82,7 @@ static int pds_vfio_dirty_alloc_bitmaps(struct pds_vfio_region *region,
>  
>  	host_ack_bmp = vzalloc(bytes);
>  	if (!host_ack_bmp) {
> -		bitmap_free(host_seq_bmp);
> +		vfree(host_seq_bmp);
>  		return -ENOMEM;
>  	}
>  


      parent reply	other threads:[~2025-09-13  8:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-12 15:04 Zilin Guan
2025-09-12 16:55 ` Markus Elfring
2025-09-13  8:02 ` Alex Williamson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250913090250.0cde9ca3.alex.williamson@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=brett.creeley@amd.com \
    --cc=jgg@ziepe.ca \
    --cc=jianhao.xu@seu.edu.cn \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=yishaih@nvidia.com \
    --cc=zilin@seu.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®