drm/nouveau/svm: fail NOUVEAU_SVM_INIT ioctl on unsupported devices
authorKarol Herbst <kherbst@redhat.com>
Mon, 18 Jan 2021 17:16:06 +0000 (18:16 +0100)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 29 Jan 2021 01:03:11 +0000 (11:03 +1000)
Fixes a crash when trying to create a channel on e.g. Turing GPUs when
NOUVEAU_SVM_INIT was called before.

Fixes: eeaf06ac1a558 ("drm/nouveau/svm: initial support for shared virtual memory")
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_svm.c

index 4f69e4c3dafde298f6f7707b719a074a5dca5076..1c3f890377d2c283220c2868c389c4135c332eae 100644 (file)
@@ -315,6 +315,10 @@ nouveau_svmm_init(struct drm_device *dev, void *data,
        struct drm_nouveau_svm_init *args = data;
        int ret;
 
+       /* We need to fail if svm is disabled */
+       if (!cli->drm->svm)
+               return -ENOSYS;
+
        /* Allocate tracking for SVM-enabled VMM. */
        if (!(svmm = kzalloc(sizeof(*svmm), GFP_KERNEL)))
                return -ENOMEM;