From: iamhswang@gmail.com
To: richard@nod.at, anton.ivanov@cambridgegreys.com,
johannes@sipsolutions.net, akpm@linux-foundation.org,
dave.hansen@linux.intel.com, tiwei.btw@antgroup.com,
rppt@kernel.org, kevin.brodsky@arm.com, snovitoll@gmail.com,
linux@weissschuh.net
Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org,
iamhswang@gmail.com
Subject: [PATCH 2/2] um: use uml_kmalloc_array() instead of uml_malloc()
Date: Tue, 20 Jan 2026 19:28:55 +0800 [thread overview]
Message-ID: <20260120112938.463596-2-iamhswang@gmail.com> (raw)
In-Reply-To: <20260120112938.463596-1-iamhswang@gmail.com>
From: Haisu Wang <iamhswang@gmail.com>
Replace uml_kmalloc() with uml_kmalloc_array() for multiplication.
Signed-off-by: Haisu Wang <wanghs18@chinatelecom.cn>
---
arch/um/drivers/vector_user.c | 4 ++--
arch/um/drivers/vfio_user.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c
index 2ea67e6fd067..adc4280691cf 100644
--- a/arch/um/drivers/vector_user.c
+++ b/arch/um/drivers/vector_user.c
@@ -868,8 +868,8 @@ void *uml_vector_default_bpf(const void *mac)
} else {
return NULL;
}
- bpf = uml_kmalloc(
- sizeof(struct sock_filter) * DEFAULT_BPF_LEN, UM_GFP_KERNEL);
+ bpf = uml_kmalloc_array(DEFAULT_BPF_LEN, sizeof(struct sock_filter),
+ UM_GFP_KERNEL);
if (bpf) {
bpf_prog->filter = bpf;
/* ld [8] */
diff --git a/arch/um/drivers/vfio_user.c b/arch/um/drivers/vfio_user.c
index 6a45d8e14582..4ad8c8c59e9d 100644
--- a/arch/um/drivers/vfio_user.c
+++ b/arch/um/drivers/vfio_user.c
@@ -194,7 +194,7 @@ int uml_vfio_user_setup_device(struct uml_vfio_user_device *dev,
if (dev->num_regions > VFIO_PCI_CONFIG_REGION_INDEX + 1)
dev->num_regions = VFIO_PCI_CONFIG_REGION_INDEX + 1;
- dev->region = uml_kmalloc(sizeof(*dev->region) * dev->num_regions,
+ dev->region = uml_kmalloc_array(dev->num_regions, sizeof(*dev->region),
UM_GFP_KERNEL);
if (!dev->region) {
err = -ENOMEM;
@@ -223,7 +223,7 @@ int uml_vfio_user_setup_device(struct uml_vfio_user_device *dev,
dev->irq_count = irq_info.count;
- dev->irqfd = uml_kmalloc(sizeof(int) * dev->irq_count, UM_GFP_KERNEL);
+ dev->irqfd = uml_kmalloc_array(dev->irq_count, sizeof(int), UM_GFP_KERNEL);
if (!dev->irqfd) {
err = -ENOMEM;
goto free_region;
--
2.52.0
prev parent reply other threads:[~2026-01-20 11:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-20 11:28 [PATCH 1/2] um: add uml_kmalloc_array() helper to avoid potential iamhswang
2026-01-20 11:28 ` iamhswang [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=20260120112938.463596-2-iamhswang@gmail.com \
--to=iamhswang@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=anton.ivanov@cambridgegreys.com \
--cc=dave.hansen@linux.intel.com \
--cc=johannes@sipsolutions.net \
--cc=kevin.brodsky@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=linux@weissschuh.net \
--cc=richard@nod.at \
--cc=rppt@kernel.org \
--cc=snovitoll@gmail.com \
--cc=tiwei.btw@antgroup.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