[PATCH 1/7] nouveau/gsp/rm: Fix NULL return values in message receive functions
From: Hongling Zeng
Date: Fri May 29 2026 - 00:49:51 EST
Fix r535_gsp_msgq_recv() and r535_gsp_msg_recv() to return error
pointers instead of NULL. This is necessary to allow callers to use
IS_ERR() consistently without missing NULL cases.
Changes:
- r535_gsp_msgq_recv(): Return ERR_PTR(-EINVAL) when RPC size exceeds
maximum instead of NULL
- r535_gsp_msg_recv(): Return ERR_PTR(-EIO) when message length is
insufficient instead of NULL
- r535_gsp_msg_recv(): For the case where no reply payload is expected
(gsp_rpc_len == 0), return ERR_PTR(-EIO) instead of NULL to maintain
consistent error handling
This fixes potential NULL pointer dereferences when IS_ERR_OR_NULL()
is replaced with IS_ERR().
Fixes: ("nouveau/gsp/rm: cleanup IS_ERR_OR_NULL in core implementation")
Fixes: ("nouveau/gsp/rm: cleanup remaining IS_ERR_OR_NULL usage")
Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
---
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c
index 3ca3de8f4340..ce83a867dd36 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c
@@ -297,7 +297,7 @@ r535_gsp_msgq_recv(struct nvkm_gsp *gsp, u32 gsp_rpc_len, int *retries)
rpc = (struct nvfw_gsp_rpc *)mqe->data;
if (WARN_ON(rpc->length > max_rpc_size))
- return NULL;
+ return ERR_PTR(-EINVAL);
buf = kvmalloc(max_t(u32, rpc->length, expected), GFP_KERNEL);
if (!buf)
@@ -488,7 +488,7 @@ r535_gsp_msg_recv(struct nvkm_gsp *gsp, int fn, u32 gsp_rpc_len)
}
r535_gsp_msg_done(gsp, rpc);
- return NULL;
+ return ERR_PTR(-EIO);
}
for (i = 0; i < gsp->msgq.ntfy_nr; i++) {
@@ -512,7 +512,7 @@ r535_gsp_msg_recv(struct nvkm_gsp *gsp, int fn, u32 gsp_rpc_len)
if (*gsp->msgq.rptr != *gsp->msgq.wptr)
goto retry;
- return NULL;
+ return ERR_PTR(-EIO);
}
int
--
2.25.1