drm/nouveau/gsp: Fix possible NULL pointer dereference warning in r535_dmac_alloc
Subsystems (3)
PATCH 1/1 drm/nouveau/gsp: Fix possible NULL pointer dereference warning in r535_dmac_alloc
From: sunliming <[email protected]>
Fix below smatch warnings:drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c:178 r535_dmac_alloc()
warn: 'args' can also be NULL
--- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c +2 -0
@@ -172,6 +172,8 @@ r535_dmac_alloc(struct nvkm_disp *disp, u32 oclass, int inst, u32 put_offset, args =nvkm_gsp_rm_alloc_get (&disp->rm.object, (oclass <<16 ) | inst, oclass,sizeof (*args), dmac); +if (!args) +return -ENOMEM ;if (IS_ERR (args))return PTR_ERR (args);
Signature · 1 line
2.25.1
Danilo Krummrich
maintainerQuoted 5 lines · sunliming
From: sunliming <[email protected]>
Fix below smatch warnings:
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c:178r535_dmac_alloc()
warn: 'args' can also be NULL
Please write a commit description that explains also the underlying problem; see more below.
Quoted 10 lines
Signed-off-by sunliming <[email protected]>--- drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c +0
-0
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c r535_dmac_alloc(struct nvkm_disp *disp, u32 oclass, int inst, u32 put_offset, · line 176
Quoted 5 lines
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c +2
-0@@ -172,6 +172,8 @@ r535_dmac_alloc(struct nvkm_disp *disp, u32 oclass, int inst, u32 put_offset, args =nvkm_gsp_rm_alloc_get (&disp->rm.object, (oclass <<16 ) | inst, oclass,sizeof (*args), dmac); +if (!args) +return -ENOMEM ;
Are we sure that this can ever return NULL in the first place? I know that nvkm_gsp_rm_alloc_get() internally checks for IS_ERR_OR_NULL(), but I couldn't find anything within the callchain that would actually return NULL.
That said, I think IS_ERR_OR_NULL() checks are misleading.
Quoted 5 lines
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c +0
-0if (IS_ERR (args))return PTR_ERR (args);Signature · 1 line
2.25.1
Quoted 5 lines · Danilo Krummrich
Are we sure that this can ever return NULL in the first place? I know that
nvkm_gsp_rm_alloc_get()internally checks forIS_ERR_OR_NULL(), but I couldn't find anything within the callchain that would actually return NULL.That said, I think
IS_ERR_OR_NULL()checks are misleading.
I posted a patch a couple months ago that cleans up an IS_ERR check, but it was never picked up:
https://lore.freedesktop.org/nouveau/[email protected]/T/#u
I'm quite certain that there are other similar issues in Nouveau w.r.t. IS_ERR_OR_NULL.
I think an audit of the Nouveau error paths is in order. I suspect that Ben's big refactors over the past year have resulted in some invalid error paths.
Danilo Krummrich
maintainerQuoted 8 lines · Timur Tabi
Quoted 5 lines · Danilo Krummrich
Are we sure that this can ever return NULL in the first place? I know that
nvkm_gsp_rm_alloc_get()internally checks forIS_ERR_OR_NULL(), but I couldn't find anything within the callchain that would actually return NULL.That said, I think
IS_ERR_OR_NULL()checks are misleading.I posted a patch a couple months ago that cleans up an
IS_ERRcheck, but it was never picked up:
Thanks! Can you please make sure to send patches to all maintainers? If they don't land in my inbox, I can't pick them up. :(
Quoted 3 lines
https://lore.freedesktop.org/nouveau/[email protected]/T/#u
I'm quite certain that there are other similar issues in Nouveau w.r.t.
IS_ERR_OR_NULL.
Yeah, that sounds likely.
Quoted 2 lines
I think an audit of the Nouveau error paths is in order. I suspect that Ben's big refactors over the past year have resulted in some invalid error paths.
Are you planning to look into this?
Thanks,
Danilo
Quoted 5 lines · Danilo Krummrich
Quoted 2 lines
I posted a patch a couple months ago that cleans up an
IS_ERRcheck, but it was never picked up:Thanks! Can you please make sure to send patches to all maintainers? If they don't land in my inbox, I can't pick them up. :(
M: Lyude Paul <[email protected]> M: Danilo Krummrich <[email protected]>
Hmmmm.... I did CC Lyude, but you're right. I should update my git-email script to catch these better.
While I have your attention, I do have other patches that I neglected to CC you on:
2. [PATCH 6/6] drm/nouveau/gsp: enable FWSEC-SB on GA100
- by Timur Tabi @ 2026-04-07 19:21 UTC [95%]
3. [PATCH 2/6] drm/nouveau/bios: specify correct display fuse register for Ampere and Ada
- by Timur Tabi @ 2026-04-07 19:21 UTC [95%]
4. [PATCH 1/6] drm/nouveau: check for GA100 specifically when calculating FRTS size
- by Timur Tabi @ 2026-04-07 19:21 UTC [91%]
5. [PATCH 4/6] drm/nouveau/gsp: require GSP-RM for GA100 support
- by Timur Tabi @ 2026-04-07 19:21 UTC [97%]
6. [PATCH 3/6] drm/nouveau/bios: skip the IFR header if present
- by Timur Tabi @ 2026-04-07 19:21 UTC [75%]
7. [PATCH 5/6] drm/nouveau: parse the VBIOS on GA100
- by Timur Tabi @ 2026-04-07 19:21 UTC [99%]
8. [PATCH 0/6] drm/nouveau: fix GA100 issues
- by Timur Tabi @ 2026-04-07 19:21 UTC [93%]
9. [PATCH] drm/nouveau: expose VBIOS via debugfs on GSP-RM systems
- by Timur Tabi @ 2026-04-07 18:53 UTC [95%]
Quoted 11 lines
Quoted 4 lines
https://lore.freedesktop.org/nouveau/[email protected]/T/#u
I'm quite certain that there are other similar issues in Nouveau w.r.t.
IS_ERR_OR_NULL.Yeah, that sounds likely.
Quoted 2 lines
I think an audit of the Nouveau error paths is in order. I suspect that Ben's big refactors over the past year have resulted in some invalid error paths.
Are you planning to look into this?
No, but it does sound like something that Claude could figure out pretty quick.
Danilo Krummrich
maintainerQuoted 30 lines · Timur Tabi
Quoted 5 lines · Danilo Krummrich
Quoted 2 lines
I posted a patch a couple months ago that cleans up an
IS_ERRcheck, but it was never picked up:Thanks! Can you please make sure to send patches to all maintainers? If they don't land in my inbox, I can't pick them up. :(
M: Lyude Paul <[email protected]> M: Danilo Krummrich <[email protected]>Hmmmm.... I did CC Lyude, but you're right. I should update my git-email script to catch these better.
While I have your attention, I do have other patches that I neglected to CC you on:
2. [PATCH 6/6] drm/nouveau/gsp: enable FWSEC-SB on GA100
- by Timur Tabi @ 2026-04-07 19:21 UTC [95%]3. [PATCH 2/6] drm/nouveau/bios: specify correct display fuse register for Ampere and Ada
- by Timur Tabi @ 2026-04-07 19:21 UTC [95%]4. [PATCH 1/6] drm/nouveau: check for GA100 specifically when calculating FRTS size
- by Timur Tabi @ 2026-04-07 19:21 UTC [91%]5. [PATCH 4/6] drm/nouveau/gsp: require GSP-RM for GA100 support
- by Timur Tabi @ 2026-04-07 19:21 UTC [97%]6. [PATCH 3/6] drm/nouveau/bios: skip the IFR header if present
- by Timur Tabi @ 2026-04-07 19:21 UTC [75%]
Quoted 8 lines
7. [PATCH 5/6] drm/nouveau: parse the VBIOS on GA100
- by Timur Tabi @ 2026-04-07 19:21 UTC [99%]8. [PATCH 0/6] drm/nouveau: fix GA100 issues
- by Timur Tabi @ 2026-04-07 19:21 UTC [93%]9. [PATCH] drm/nouveau: expose VBIOS via debugfs on GSP-RM systems
- by Timur Tabi @ 2026-04-07 18:53 UTC [95%]
Ok, I will take a look in the next days.
Thanks,
Danilo
Quoted 12 lines
Quoted 10 lines
Quoted 3 lines
https://lore.freedesktop.org/nouveau/[email protected]/T/#u
I'm quite certain that there are other similar issues in Nouveau w.r.t.
IS_ERR_OR_NULL.Yeah, that sounds likely.
Quoted 2 lines
I think an audit of the Nouveau error paths is in order. I suspect that Ben's big refactors over the past year have resulted in some invalid error paths.
Are you planning to look into this?
No, but it does sound like something that Claude could figure out pretty quick.
2026年4月18日 20:12, "Danilo Krummrich" <[email protected] mailto:[email protected]?to=%22Danilo%20Krummrich%22%20%3Cdakr%40kernel.org%3E > 写到:
Quoted 30 lines · sunliming
Quoted 8 lines
From: sunliming <[email protected]>
Fix below smatch warnings:
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c:178r535_dmac_alloc()
warn: 'args' can also be NULLPlease write a commit description that explains also the underlying problem; see more below.
Quoted 12 lines
Signed-off-by sunliming <[email protected]>---
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c | 2 ++ 1 file changed, 2 insertions(+)diff --git
a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.cb/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.cindex6e63df816d85..6dec2623d0be100644
---a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
+++b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
@@ -172,6 +172,8 @@ r535_dmac_alloc(structnvkm_disp*disp, u32 oclass, int inst, u32put_offset,Quoted 5 lines
args =
nvkm_gsp_rm_alloc_get(&disp->rm.object, (oclass << 16) | inst, oclass, sizeof(*args), dmac);
+ if (!args)
+ return-ENOMEM;
Quoted 6 lines
Are we sure that this can ever return NULL in the first place? I know that
nvkm_gsp_rm_alloc_get()internally checks forIS_ERR_OR_NULL(), but I couldn't find anything within the callchain that would actually return NULL.That said, I think
IS_ERR_OR_NULL()checks are misleading.
I also believe that the nvkm_gsp_rm_alloc_get function will not return NULL. My patch was merely intended to suppress a compiler warning and to guard against possible future changes in the implementation of nvkm_gsp_rm_alloc_get. Of course, the patch may be unnecessary, and I will defer to the maintainers' review conclusion.
Thanks.
Quoted 8 lines
Quoted 7 lines
if (
IS_ERR(args))
returnPTR_ERR(args);--
2.25.1