From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: "Dan Carpenter" <dan.carpenter@linaro.org>,
"Michał Winiarski" <michal.winiarski@intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Yishai Hadas <yishaih@nvidia.com>,
"Shameer Kolothum" <skolothumtho@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>,
"Alex Williamson" <alex@shazbot.org>,
Rodrigo Vivi <rodrigo.vivi@intel.com>, <kvm@vger.kernel.org>,
<intel-xe@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH next] vfio/xe: Fix use after free in xe_vfio_pci_alloc_file()
Date: Fri, 5 Dec 2025 13:31:04 +0100 [thread overview]
Message-ID: <88c3e5b4-8ac2-42fc-acf0-2aec2406a7ef@intel.com> (raw)
In-Reply-To: <aTLEXt_h5bWRWC0Z@stanley.mountain>
On 12/5/2025 12:39 PM, Dan Carpenter wrote:
> This code frees "migf" and then dereferences it on the next line to get
> the error code. Preserve the error code before freeing the pointer.
>
> Fixes: 2e38c50ae492 ("vfio/xe: Add device specific vfio_pci driver variant for Intel graphics")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> ---
> drivers/vfio/pci/xe/main.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/pci/xe/main.c b/drivers/vfio/pci/xe/main.c
> index 0156b53c678b..8e1595e00e18 100644
> --- a/drivers/vfio/pci/xe/main.c
> +++ b/drivers/vfio/pci/xe/main.c
> @@ -250,6 +250,7 @@ xe_vfio_pci_alloc_file(struct xe_vfio_pci_core_device *xe_vdev,
> struct xe_vfio_pci_migration_file *migf;
> const struct file_operations *fops;
> int flags;
> + int ret;
>
> migf = kzalloc(sizeof(*migf), GFP_KERNEL_ACCOUNT);
> if (!migf)
> @@ -259,8 +260,9 @@ xe_vfio_pci_alloc_file(struct xe_vfio_pci_core_device *xe_vdev,
> flags = type == XE_VFIO_FILE_SAVE ? O_RDONLY : O_WRONLY;
> migf->filp = anon_inode_getfile("xe_vfio_mig", fops, migf, flags);
> if (IS_ERR(migf->filp)) {
> + ret = PTR_ERR(migf->filp);
> kfree(migf);
> - return ERR_CAST(migf->filp);
> + return ERR_PTR(ret);
> }
>
> mutex_init(&migf->lock);
next prev parent reply other threads:[~2025-12-05 12:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 11:39 [PATCH next] vfio/xe: Fix use after free in xe_vfio_pci_alloc_file() Dan Carpenter
2025-12-05 12:31 ` Michal Wajdeczko [this message]
2025-12-05 13:47 ` ✓ CI.KUnit: success for " Patchwork
2025-12-05 14:50 ` ✓ Xe.CI.BAT: " Patchwork
2025-12-05 17:38 ` ✗ Xe.CI.Full: failure " Patchwork
2025-12-12 4:07 ` [PATCH next] " Tian, Kevin
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=88c3e5b4-8ac2-42fc-acf0-2aec2406a7ef@intel.com \
--to=michal.wajdeczko@intel.com \
--cc=alex@shazbot.org \
--cc=dan.carpenter@linaro.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=kernel-janitors@vger.kernel.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.winiarski@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=skolothumtho@nvidia.com \
--cc=yishaih@nvidia.com \
/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