Qianfeng Rong
2025-Aug-13 12:54 UTC
[PATCH v2] drm/nouveau/gsp: fix mismatched alloc/free for kvmalloc()
Replace kfree() with kvfree() for memory allocated by kvmalloc().
Compile-tested only.
Cc: stable at vger.kernel.org
Fixes: 8a8b1ec5261f ("drm/nouveau/gsp: split rpc handling out on its
own")
Signed-off-by: Qianfeng Rong <rongqianfeng at vivo.com>
Reviewed-by: Timur Tabi <ttabi at nvidia.com>
Acked-by: Zhi Wang <zhiw at nvidia.com>
---
v2: Add a Fixes: tag.
---
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c | 4 ++--
1 file changed, 2 insertions(+), 2 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 9d06ff722fea..0dc4782df8c0 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
@@ -325,7 +325,7 @@ r535_gsp_msgq_recv(struct nvkm_gsp *gsp, u32 gsp_rpc_len,
int *retries)
rpc = r535_gsp_msgq_peek(gsp, sizeof(*rpc), info.retries);
if (IS_ERR_OR_NULL(rpc)) {
- kfree(buf);
+ kvfree(buf);
return rpc;
}
@@ -334,7 +334,7 @@ r535_gsp_msgq_recv(struct nvkm_gsp *gsp, u32 gsp_rpc_len,
int *retries)
rpc = r535_gsp_msgq_recv_one_elem(gsp, &info);
if (IS_ERR_OR_NULL(rpc)) {
- kfree(buf);
+ kvfree(buf);
return rpc;
}
--
2.34.1
Markus Elfring
2025-Aug-14 12:41 UTC
[PATCH v2] drm/nouveau/gsp: fix mismatched alloc/free for kvmalloc()
> Replace kfree() with kvfree() for memory allocated by kvmalloc().* Would you like to improve the exception handling by using another goto chain? * How do you think about to increase the application of scope-based resource management? https://elixir.bootlin.com/linux/v6.16/source/include/linux/slab.h#L1081 Is there a need to adjust also the following statement combination? https://elixir.bootlin.com/linux/v6.16/source/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c#L312-L314 ? kvfree(info.gsp_rpc_buf); info.gsp_rpc_buf = NULL; return buf; ? Regards, Markus
Danilo Krummrich
2025-Aug-15 20:57 UTC
[PATCH v2] drm/nouveau/gsp: fix mismatched alloc/free for kvmalloc()
On 8/13/25 2:54 PM, Qianfeng Rong wrote:> Replace kfree() with kvfree() for memory allocated by kvmalloc(). > > Compile-tested only. > > Cc: stable at vger.kernel.org > Fixes: 8a8b1ec5261f ("drm/nouveau/gsp: split rpc handling out on its own") > Signed-off-by: Qianfeng Rong <rongqianfeng at vivo.com> > Reviewed-by: Timur Tabi <ttabi at nvidia.com> > Acked-by: Zhi Wang <zhiw at nvidia.com>Applied to drm-misc-fixes, thanks!