public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member
@ 2023-08-16 18:03 Gustavo A. R. Silva
  2023-08-16 18:04 ` [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm Gustavo A. R. Silva
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-08-16 18:03 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter
  Cc: dri-devel, nouveau, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

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(-)

-- 
2.34.1


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

* [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm
  2023-08-16 18:03 [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Gustavo A. R. Silva
@ 2023-08-16 18:04 ` Gustavo A. R. Silva
  2023-08-16 20:38   ` Kees Cook
  2023-08-16 18:05 ` [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional Gustavo A. R. Silva
  2023-09-29 18:20 ` [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Kees Cook
  2 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-08-16 18:04 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter
  Cc: dri-devel, nouveau, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

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 <gustavoars@kernel.org>
---
 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


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

* [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional
  2023-08-16 18:03 [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Gustavo A. R. Silva
  2023-08-16 18:04 ` [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm Gustavo A. R. Silva
@ 2023-08-16 18:05 ` Gustavo A. R. Silva
  2023-08-16 20:38   ` Kees Cook
  2023-09-29 18:20 ` [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Kees Cook
  2 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-08-16 18:05 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter
  Cc: dri-devel, nouveau, linux-kernel, Gustavo A. R. Silva,
	linux-hardening

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

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/gpu/drm/nouveau/nouveau_svm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 00444ad82d18..cc03e0c22ff3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -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;
-- 
2.34.1


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

* Re: [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm
  2023-08-16 18:04 ` [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm Gustavo A. R. Silva
@ 2023-08-16 20:38   ` Kees Cook
  0 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2023-08-16 20:38 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter,
	dri-devel, nouveau, linux-kernel, linux-hardening

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 <gustavoars@kernel.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

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

* Re: [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional
  2023-08-16 18:05 ` [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional Gustavo A. R. Silva
@ 2023-08-16 20:38   ` Kees Cook
  0 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2023-08-16 20:38 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter,
	dri-devel, nouveau, linux-kernel, linux-hardening

On Wed, Aug 16, 2023 at 12:05:06PM -0600, Gustavo A. R. Silva wrote:
> Fix checkpatch.pl ERROR: do not use assignment in if condition.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

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

* Re: [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member
  2023-08-16 18:03 [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Gustavo A. R. Silva
  2023-08-16 18:04 ` [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm Gustavo A. R. Silva
  2023-08-16 18:05 ` [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional Gustavo A. R. Silva
@ 2023-09-29 18:20 ` Kees Cook
  2 siblings, 0 replies; 6+ messages in thread
From: Kees Cook @ 2023-09-29 18:20 UTC (permalink / raw)
  To: Ben Skeggs, Karol Herbst, Lyude Paul, David Airlie, Daniel Vetter,
	Gustavo A. R. Silva
  Cc: Kees Cook, dri-devel, nouveau, linux-kernel, linux-hardening

On Wed, 16 Aug 2023 12:03:06 -0600, Gustavo A. R. Silva wrote:
> 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,

-- 
Kees Cook


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

end of thread, other threads:[~2023-09-29 18:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-16 18:03 [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Gustavo A. R. Silva
2023-08-16 18:04 ` [PATCH 1/2][next] nouveau/svm: Replace one-element array with flexible-array member in struct nouveau_svm Gustavo A. R. Silva
2023-08-16 20:38   ` Kees Cook
2023-08-16 18:05 ` [PATCH 2/2][next] nouveau/svm: Split assignment from if conditional Gustavo A. R. Silva
2023-08-16 20:38   ` Kees Cook
2023-09-29 18:20 ` [PATCH 0/2][next] nouveau/svm: Replace one-element array with flexible-array member Kees Cook

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