public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390/vfio-ap: Replace one-element array with flexible array member
@ 2025-01-16 13:18 Thorsten Blum
  2025-01-28 13:56 ` Alexander Gordeev
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Thorsten Blum @ 2025-01-16 13:18 UTC (permalink / raw)
  To: Tony Krowiak, Halil Pasic, Jason Herne, Harald Freudenberger,
	Holger Dengler, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle
  Cc: linux-hardening, Thorsten Blum, linux-s390, linux-kernel

Replace the deprecated one-element array with a modern flexible array
member in the struct ap_matrix_dev.

Use struct_size() to calculate the number of bytes to allocate for
matrix_dev with a single mdev_type.

Link: https://github.com/KSPP/linux/issues/79
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/s390/crypto/vfio_ap_drv.c     | 2 +-
 drivers/s390/crypto/vfio_ap_private.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c
index 67a807e2e75b..ea9ffa37f263 100644
--- a/drivers/s390/crypto/vfio_ap_drv.c
+++ b/drivers/s390/crypto/vfio_ap_drv.c
@@ -96,7 +96,7 @@ static int vfio_ap_matrix_dev_create(void)
 	if (ret)
 		goto bus_register_err;
 
-	matrix_dev = kzalloc(sizeof(*matrix_dev), GFP_KERNEL);
+	matrix_dev = kzalloc(struct_size(matrix_dev, mdev_types, 1), GFP_KERNEL);
 	if (!matrix_dev) {
 		ret = -ENOMEM;
 		goto matrix_alloc_err;
diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h
index 437a161c8659..9aed8994f567 100644
--- a/drivers/s390/crypto/vfio_ap_private.h
+++ b/drivers/s390/crypto/vfio_ap_private.h
@@ -53,7 +53,7 @@ struct ap_matrix_dev {
 	struct mutex guests_lock; /* serializes access to each KVM guest */
 	struct mdev_parent parent;
 	struct mdev_type mdev_type;
-	struct mdev_type *mdev_types[1];
+	struct mdev_type *mdev_types[];
 };
 
 extern struct ap_matrix_dev *matrix_dev;
-- 
2.48.0


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

end of thread, other threads:[~2025-01-31  8:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 13:18 [PATCH] s390/vfio-ap: Replace one-element array with flexible array member Thorsten Blum
2025-01-28 13:56 ` Alexander Gordeev
2025-01-29 14:27 ` Anthony Krowiak
2025-01-29 15:53 ` Alexander Gordeev
2025-01-29 20:38 ` Halil Pasic
2025-01-30  0:00   ` Gustavo A. R. Silva
2025-01-30 10:46     ` Halil Pasic
2025-01-30 11:37       ` Alexander Gordeev
2025-01-30 12:46         ` Heiko Carstens
2025-01-31  8:06           ` Halil Pasic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox