Skip to contentSkip to conversation

nouveau/svm: Replace one-element array with flexible-array member

PATCH Applied Gustavo A. R. Silva 2 participants 6 messages Aug 16, 2023 – Sep 29, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover nouveau/svm: Replace one-element array with flexible-array member

This small series aims to replace a one-element array with a flexible-array member in struct nouveau_svm. And, while at it, fix a checkpatch.pl error.

Gustavo A. R. Silva (2):
nouveau/svm: Replace one-element array with flexible-array member in
struct nouveau_svm
nouveau/svm: Split assignment from if conditional

 drivers/gpu/drm/nouveau/nouveau_svm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

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

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.

---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_svm.c +2 -2
index 186351ecf72f..00444ad82d18 100644
@@ -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;
Signature · 1 line
2.34.1
#3 lore raw

PATCH 2/2 nouveau/svm: Split assignment from if conditional

In reply to Gustavo A. R. Silva

Fix checkpatch.pl ERROR: do not use assignment in if condition.

---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_svm.c +2 -1
index 00444ad82d18..cc03e0c22ff3 100644
@@ -1063,7 +1063,8 @@ nouveau_svm_init(struct nouveau_drm *drm)
 	if (drm->client.device.info.family > NV_DEVICE_INFO_V0_PASCAL)
 		return;
 
-	if (!(drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), GFP_KERNEL)))
+	drm->svm = svm = kzalloc(struct_size(drm->svm, buffer, 1), GFP_KERNEL);
+	if (!drm->svm)
 		return;
 
 	drm->svm->drm = drm;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

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

In reply to Gustavo A. R. Silva
Quoted 7 lines · 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.

Signature · 1 line
Kees Cook
Applied
#5 lore raw
In reply to Gustavo A. R. Silva
Quoted 10 lines · Gustavo A. R. Silva

This small series aims to replace a one-element array with a flexible-array member in struct nouveau_svm. And, while at it, fix a checkpatch.pl error.

Gustavo A. R. Silva (2):
nouveau/svm: Replace one-element array with flexible-array member in
struct nouveau_svm
nouveau/svm: Split assignment from if conditional

[...]

These look trivially correct and haven't had further feedback for over a month.

Applied to for-next/hardening, thanks!

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

      https://git.kernel.org/kees/c/6ad33b53c9b8
[2/2] nouveau/svm: Split assignment from if conditional
      https://git.kernel.org/kees/c/4cb2e89fea5f

Take care,

Signature · 1 line
Kees Cook