From: SF Markus Elfring <elfring@users.sourceforge.net>
To: virtualization@lists.linux-foundation.org,
Jason Wang <jasowang@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
Date: Thu, 26 Jan 2017 22:46:57 +0100 [thread overview]
Message-ID: <02a6f5e2-d20b-3e71-5eaa-344331bec7f1@users.sourceforge.net> (raw)
In-Reply-To: <61829748-a13d-42e4-8f6c-103ee5ca2c88@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:20:30 +0100
A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus reuse the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/virtio/virtio_pci_common.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 559a2b706093..623a8cea1441 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -111,9 +111,9 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
int err = -ENOMEM;
vp_dev->msix_vectors = nvectors;
-
- vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names,
- GFP_KERNEL);
+ vp_dev->msix_names = kmalloc_array(nvectors,
+ sizeof(*vp_dev->msix_names),
+ GFP_KERNEL);
if (!vp_dev->msix_names)
goto error;
vp_dev->msix_affinity_masks
--
2.11.0
next prev parent reply other threads:[~2017-01-26 21:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <61829748-a13d-42e4-8f6c-103ee5ca2c88@users.sourceforge.net>
2017-01-26 21:46 ` [PATCH 1/3] virtio_pci: Use kcalloc() in vp_request_msix_vectors() SF Markus Elfring
2017-01-26 21:46 ` SF Markus Elfring [this message]
2017-01-26 21:47 ` [PATCH 3/3] virtio_ring: Use kmalloc_array() in alloc_indirect() SF Markus Elfring
2017-02-03 2:57 ` [PATCH 0/3] Virtio: Fine-tuning for two function implementations Jason Wang
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=02a6f5e2-d20b-3e71-5eaa-344331bec7f1@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=jasowang@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).