Re: [Nouveau] [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm

2023-08-16 Thread Kees Cook
On Wed, Aug 16, 2023 at 12:04:06PM -0600, Gustavo A. R. Silva wrote:
> One-element and zero-length arrays are deprecated. So, replace
> one-element array in struct nouveau_svm with flexible-array member.
> 
> This results in no differences in binary output.
> 
> Link: https://github.com/KSPP/linux/issues/338
> Signed-off-by: Gustavo A. R. Silva 

Reviewed-by: Kees Cook 

-- 
Kees Cook


[Nouveau] [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm

2023-08-16 Thread Gustavo A. R. Silva
One-element and zero-length arrays are deprecated. So, replace
one-element array in struct nouveau_svm with flexible-array member.

This results in no differences in binary output.

Link: https://github.com/KSPP/linux/issues/338
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c 
b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 186351ecf72f..00444ad82d18 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -67,7 +67,7 @@ struct nouveau_svm {
struct nouveau_svmm *svmm;
} **fault;
int fault_nr;
-   } buffer[1];
+   } buffer[];
 };
 
 #define FAULT_ACCESS_READ 0
@@ -1063,7 +1063,7 @@ nouveau_svm_init(struct nouveau_drm *drm)
if (drm->client.device.info.family > NV_DEVICE_INFO_V0_PASCAL)
return;
 
-   if (!(drm->svm = svm = kzalloc(sizeof(*drm->svm), GFP_KERNEL)))
+   if (!(drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), 
GFP_KERNEL)))
return;
 
drm->svm->drm = drm;
-- 
2.34.1