nouveau_uvmm_sm_prepare() passes the uvmm_map_args pointer (args) to
op_map_prepare() without checking for NULL.
Prevent NULL deref in op_map_prepare() by checking args before use.

Signed-off-by: Chelsy Ratnawat <[email protected]>
---
 drivers/gpu/drm/nouveau/nouveau_uvmm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c 
b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
index 79eefdfd08a2..7a33ce63770c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -627,6 +627,10 @@ nouveau_uvmm_sm_prepare(struct nouveau_uvmm *uvmm,
                case DRM_GPUVA_OP_MAP: {
                        u64 vmm_get_range = vmm_get_end - vmm_get_start;
 
+                       if (!args) {
+                               ret = -EINVAL;
+                               goto unwind;
+                       }
                        ret = op_map_prepare(uvmm, &new->map, &op->map, args);
                        if (ret)
                                goto unwind;
-- 
2.47.3

Reply via email to