Linux IOMMU Development
 help / color / mirror / Atom feed
From: Yi Liu <yi.l.liu@intel.com>
To: jgg@nvidia.com, kevin.tian@intel.com
Cc: nicolinc@nvidia.com, yi.l.liu@intel.com,
	baolu.lu@linux.intel.com, iommu@lists.linux.dev
Subject: [PATCH 1/2] iommufd: Initialize the flags of vevent in iommufd_viommu_report_event()
Date: Mon, 24 Mar 2025 05:00:33 -0700	[thread overview]
Message-ID: <20250324120034.5940-2-yi.l.liu@intel.com> (raw)
In-Reply-To: <20250324120034.5940-1-yi.l.liu@intel.com>

The vevent->header.flags is not initialized per allocation, hence the
vevent read path may treat the vevent as lost_events_header wrongly.
Use kzalloc() to alloc memory for new vevent.

Fixes: e8e1ef9b77a7 ("iommufd/viommu: Add iommufd_viommu_report_event helper")
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
 drivers/iommu/iommufd/driver.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
index 352513974154..81e01d85b7d4 100644
--- a/drivers/iommu/iommufd/driver.c
+++ b/drivers/iommu/iommufd/driver.c
@@ -102,7 +102,7 @@ int iommufd_viommu_report_event(struct iommufd_viommu *viommu,
 		goto out_set_header;
 	}
 
-	vevent = kmalloc(struct_size(vevent, event_data, data_len), GFP_ATOMIC);
+	vevent = kzalloc(struct_size(vevent, event_data, data_len), GFP_ATOMIC);
 	if (!vevent) {
 		rc = -ENOMEM;
 		vevent = &veventq->lost_events_header;
-- 
2.34.1


  reply	other threads:[~2025-03-24 12:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-24 12:00 [PATCH 0/2] Two fixes to vevent path Yi Liu
2025-03-24 12:00 ` Yi Liu [this message]
2025-03-24 14:04   ` [PATCH 1/2] iommufd: Initialize the flags of vevent in iommufd_viommu_report_event() Nicolin Chen
2025-03-24 12:00 ` [PATCH 2/2] iommufd: Balance veventq->num_events inc/dec Yi Liu
2025-03-24 14:07   ` Nicolin Chen
2025-03-25 13:35 ` [PATCH 0/2] Two fixes to vevent path Jason Gunthorpe

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=20250324120034.5940-2-yi.l.liu@intel.com \
    --to=yi.l.liu@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=nicolinc@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