Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace fake-flex array with flex-array member in drivers/gpu/drm/nouveau/nouveau_svm.c #338

Closed
GustavoARSilva opened this issue Aug 16, 2023 · 1 comment
Assignees
Labels
[Idiom] fake flexible array [Linux] v6.7 Released in Linux kernel v6.7 [Refactor] 1-element array Conversion away from one-element array

Comments

@GustavoARSilva
Copy link
Collaborator

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[];
 };

Audit the code below:

diff -u -p ./drivers/gpu/drm/nouveau/nouveau_svm.c /tmp/nothing/drivers/gpu/drm/nouveau/nouveau_svm.c
--- ./drivers/gpu/drm/nouveau/nouveau_svm.c
+++ /tmp/nothing/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -942,7 +942,6 @@ nouveau_pfns_map(struct nouveau_svmm *sv
 static void
 nouveau_svm_fault_buffer_fini(struct nouveau_svm *svm, int id)
 {
-       struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];

        nvif_event_block(&buffer->notify);
        flush_work(&buffer->work);
@@ -951,7 +950,6 @@ nouveau_svm_fault_buffer_fini(struct nou
 static int
 nouveau_svm_fault_buffer_init(struct nouveau_svm *svm, int id)
 {
-       struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];
        struct nvif_object *device = &svm->drm->client.device.object;

        buffer->get = nvif_rd32(device, buffer->getaddr);
@@ -964,7 +962,6 @@ nouveau_svm_fault_buffer_init(struct nou
 static void
 nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
 {
-       struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];
        int i;

        if (!nvif_object_constructed(&buffer->object))
@@ -985,7 +982,6 @@ nouveau_svm_fault_buffer_dtor(struct nou
 static int
 nouveau_svm_fault_buffer_ctor(struct nouveau_svm *svm, s32 oclass, int id)
 {
-       struct nouveau_svm_fault_buffer *buffer = &svm->buffer[id];
        struct nouveau_drm *drm = svm->drm;
        struct nvif_object *device = &drm->client.device.object;
        struct nvif_clb069_v0 args = {};
@GustavoARSilva GustavoARSilva self-assigned this Aug 16, 2023
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Aug 16, 2023
…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.

Link: KSPP#338
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Oct 3, 2023
…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.

Link: KSPP#338
Signed-off-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/087a1c335228bd245192bbb2fb347c9af1be5750.1692208802.git.gustavoars@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
@kees kees added the [Linux] v6.7 Released in Linux kernel v6.7 label Feb 6, 2024
@kees
Copy link

kees commented Feb 6, 2024

Fixed in commit 6ad33b5.

@kees kees closed this as completed Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Idiom] fake flexible array [Linux] v6.7 Released in Linux kernel v6.7 [Refactor] 1-element array Conversion away from one-element array
Projects
None yet
Development

No branches or pull requests

2 participants