From nobody Wed Feb 5 19:06:31 2025 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B486F1DE2AD for ; Thu, 16 Jan 2025 13:20:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.183 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737033610; cv=none; b=bgYTzeZRXhWMx+PtgdDMW5Gjr79Lr05pGLpeOfx2Dw/UwAssbpc7ZFlND3Y4xDcIhqDyb1ymj2M/sQY2XT7I72qOu5Z6TL9p9hGnfyrz3rRZZBREBbVeUC5Eq9pVtSN0kPXxq3OdXOjXXiV7Q685nZzX8zaFSKk/YT1636tjwzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737033610; c=relaxed/simple; bh=JLbzrkPHHl4z3OfrMXHdkLR2wYyEFz7nDvkukN04Yns=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=u16ackSKcpBcsff4JyuwHfKbnESwpPyVbILcz7urmf94u4q1LuceNqUCWrFrvzi19OMZcPVoa+lgStkOD0+9qYx5PzG0D8ew+H9wsv788G3ESgis6C9774t8q7z1mRJ3l7WQwuUsL6Fz6RXxJLvDbzF/5NhRAhCJC8yMedhRD24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MR2RdUZI; arc=none smtp.client-ip=91.218.175.183 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MR2RdUZI" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737033589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=KCtIlCqqSrO4jJm7cqUf8hZlN4VmB46QY7zufEspPzQ=; b=MR2RdUZI0IBjFtTp2atANEKRTb5K+2PvOTA2NZaeYgdNKkhQQYZWxMM6nWeYUFLAhM6Jrt 4fRWK3SwWQE6PwKtZlf9t18usGoWAIuGL4gZ1iPq5yR89uRLxJQXe2LFd+tyQZc6s1brwf SBEM2bbUoxoYNb2qNzI4SQVUodGdFVM= From: Thorsten Blum To: Tony Krowiak , Halil Pasic , Jason Herne , Harald Freudenberger , Holger Dengler , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Cc: linux-hardening@vger.kernel.org, Thorsten Blum , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] s390/vfio-ap: Replace one-element array with flexible array member Date: Thu, 16 Jan 2025 14:18:59 +0100 Message-ID: <20250116131859.105756-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Anthony Krowiak --- 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_a= p_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; =20 - matrix_dev =3D kzalloc(sizeof(*matrix_dev), GFP_KERNEL); + matrix_dev =3D kzalloc(struct_size(matrix_dev, mdev_types, 1), GFP_KERNEL= ); if (!matrix_dev) { ret =3D -ENOMEM; goto matrix_alloc_err; diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vf= io_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[]; }; =20 extern struct ap_matrix_dev *matrix_dev; --=20 2.48.0