All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Virtio: Fine-tuning for two function implementations
@ 2017-01-26 21:44 ` SF Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:44 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:40:02 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  virtio_pci: Use kcalloc() in vp_request_msix_vectors()
  virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
  virtio_ring: Use kmalloc_array() in alloc_indirect()

 drivers/virtio/virtio_pci_common.c | 8 ++++----
 drivers/virtio/virtio_ring.c       | 3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 0/3] Virtio: Fine-tuning for two function implementations
@ 2017-01-26 21:44 ` SF Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:44 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:40:02 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  virtio_pci: Use kcalloc() in vp_request_msix_vectors()
  virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
  virtio_ring: Use kmalloc_array() in alloc_indirect()

 drivers/virtio/virtio_pci_common.c | 8 ++++----
 drivers/virtio/virtio_ring.c       | 3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 1/3] virtio_pci: Use kcalloc() in vp_request_msix_vectors()
  2017-01-26 21:44 ` SF Markus Elfring
@ 2017-01-26 21:46   ` SF Markus Elfring
  -1 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:46 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:10:18 +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 "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virtio/virtio_pci_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 186cbab327b8..559a2b706093 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -117,7 +117,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
 	if (!vp_dev->msix_names)
 		goto error;
 	vp_dev->msix_affinity_masks
-		= kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks,
+		= kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks),
 			  GFP_KERNEL);
 	if (!vp_dev->msix_affinity_masks)
 		goto error;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 1/3] virtio_pci: Use kcalloc() in vp_request_msix_vectors()
@ 2017-01-26 21:46   ` SF Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:46 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:10:18 +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 "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virtio/virtio_pci_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 186cbab327b8..559a2b706093 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -117,7 +117,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
 	if (!vp_dev->msix_names)
 		goto error;
 	vp_dev->msix_affinity_masks
-		= kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks,
+		= kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks),
 			  GFP_KERNEL);
 	if (!vp_dev->msix_affinity_masks)
 		goto error;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 1/3] virtio_pci: Use kcalloc() in vp_request_msix_vectors()
  2017-01-26 21:44 ` SF Markus Elfring
  (?)
  (?)
@ 2017-01-26 21:46 ` SF Markus Elfring
  -1 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:46 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:10:18 +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 "kcalloc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virtio/virtio_pci_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 186cbab327b8..559a2b706093 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -117,7 +117,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
 	if (!vp_dev->msix_names)
 		goto error;
 	vp_dev->msix_affinity_masks
-		= kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks,
+		= kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks),
 			  GFP_KERNEL);
 	if (!vp_dev->msix_affinity_masks)
 		goto error;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
  2017-01-26 21:44 ` SF Markus Elfring
  (?)
@ 2017-01-26 21:46   ` SF Markus Elfring
  -1 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:46 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
@ 2017-01-26 21:46   ` SF Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:46 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

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


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 2/3] virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
@ 2017-01-26 21:46   ` SF Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:46 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: kernel-janitors, LKML

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] virtio_ring: Use kmalloc_array() in alloc_indirect()
  2017-01-26 21:44 ` SF Markus Elfring
@ 2017-01-26 21:47   ` SF Markus Elfring
  -1 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:47 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:30:45 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virtio/virtio_ring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 409aeaa49246..34b6b694298c 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -247,8 +247,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,
 	 * virtqueue.
 	 */
 	gfp &= ~__GFP_HIGHMEM;
-
-	desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp);
+	desc = kmalloc_array(total_sg, sizeof(*desc), gfp);
 	if (!desc)
 		return NULL;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] virtio_ring: Use kmalloc_array() in alloc_indirect()
@ 2017-01-26 21:47   ` SF Markus Elfring
  0 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:47 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:30:45 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virtio/virtio_ring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 409aeaa49246..34b6b694298c 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -247,8 +247,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,
 	 * virtqueue.
 	 */
 	gfp &= ~__GFP_HIGHMEM;
-
-	desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp);
+	desc = kmalloc_array(total_sg, sizeof(*desc), gfp);
 	if (!desc)
 		return NULL;
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH 3/3] virtio_ring: Use kmalloc_array() in alloc_indirect()
  2017-01-26 21:44 ` SF Markus Elfring
                   ` (3 preceding siblings ...)
  (?)
@ 2017-01-26 21:47 ` SF Markus Elfring
  -1 siblings, 0 replies; 14+ messages in thread
From: SF Markus Elfring @ 2017-01-26 21:47 UTC (permalink / raw)
  To: virtualization, Jason Wang, Michael S. Tsirkin; +Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 26 Jan 2017 22:30:45 +0100

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/virtio/virtio_ring.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 409aeaa49246..34b6b694298c 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -247,8 +247,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,
 	 * virtqueue.
 	 */
 	gfp &= ~__GFP_HIGHMEM;
-
-	desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp);
+	desc = kmalloc_array(total_sg, sizeof(*desc), gfp);
 	if (!desc)
 		return NULL;
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/3] Virtio: Fine-tuning for two function implementations
  2017-01-26 21:44 ` SF Markus Elfring
  (?)
@ 2017-02-03  2:57   ` Jason Wang
  -1 siblings, 0 replies; 14+ messages in thread
From: Jason Wang @ 2017-02-03  2:57 UTC (permalink / raw)
  To: SF Markus Elfring, virtualization, Michael S. Tsirkin
  Cc: LKML, kernel-janitors



On 2017年01月27日 05:44, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Jan 2017 22:40:02 +0100
>
> A few update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (3):
>    virtio_pci: Use kcalloc() in vp_request_msix_vectors()
>    virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
>    virtio_ring: Use kmalloc_array() in alloc_indirect()
>
>   drivers/virtio/virtio_pci_common.c | 8 ++++----
>   drivers/virtio/virtio_ring.c       | 3 +--
>   2 files changed, 5 insertions(+), 6 deletions(-)
>

Acked-by: Jason Wang <jasowang@redhat.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/3] Virtio: Fine-tuning for two function implementations
@ 2017-02-03  2:57   ` Jason Wang
  0 siblings, 0 replies; 14+ messages in thread
From: Jason Wang @ 2017-02-03  2:57 UTC (permalink / raw)
  To: SF Markus Elfring, virtualization, Michael S. Tsirkin
  Cc: LKML, kernel-janitors



On 2017年01月27日 05:44, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Jan 2017 22:40:02 +0100
>
> A few update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (3):
>    virtio_pci: Use kcalloc() in vp_request_msix_vectors()
>    virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
>    virtio_ring: Use kmalloc_array() in alloc_indirect()
>
>   drivers/virtio/virtio_pci_common.c | 8 ++++----
>   drivers/virtio/virtio_ring.c       | 3 +--
>   2 files changed, 5 insertions(+), 6 deletions(-)
>

Acked-by: Jason Wang <jasowang@redhat.com>

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 0/3] Virtio: Fine-tuning for two function implementations
@ 2017-02-03  2:57   ` Jason Wang
  0 siblings, 0 replies; 14+ messages in thread
From: Jason Wang @ 2017-02-03  2:57 UTC (permalink / raw)
  To: SF Markus Elfring, virtualization, Michael S. Tsirkin
  Cc: kernel-janitors, LKML



On 2017年01月27日 05:44, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 26 Jan 2017 22:40:02 +0100
>
> A few update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (3):
>    virtio_pci: Use kcalloc() in vp_request_msix_vectors()
>    virtio_pci: Use kmalloc_array() in vp_request_msix_vectors()
>    virtio_ring: Use kmalloc_array() in alloc_indirect()
>
>   drivers/virtio/virtio_pci_common.c | 8 ++++----
>   drivers/virtio/virtio_ring.c       | 3 +--
>   2 files changed, 5 insertions(+), 6 deletions(-)
>

Acked-by: Jason Wang <jasowang@redhat.com>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-02-03  2:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 21:44 [PATCH 0/3] Virtio: Fine-tuning for two function implementations SF Markus Elfring
2017-01-26 21:44 ` SF Markus Elfring
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
2017-01-26 21:46 ` SF Markus Elfring
2017-01-26 21:46 ` [PATCH 2/3] virtio_pci: Use kmalloc_array() " SF Markus Elfring
2017-01-26 21:46   ` SF Markus Elfring
2017-01-26 21:46   ` SF Markus Elfring
2017-01-26 21:47 ` [PATCH 3/3] virtio_ring: Use kmalloc_array() in alloc_indirect() SF Markus Elfring
2017-01-26 21:47 ` SF Markus Elfring
2017-01-26 21:47   ` SF Markus Elfring
2017-02-03  2:57 ` [PATCH 0/3] Virtio: Fine-tuning for two function implementations Jason Wang
2017-02-03  2:57   ` Jason Wang
2017-02-03  2:57   ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.