drm/nouveau: Fix potential memory leak in nouveau_drm_load()
authorLyude Paul <lyude@redhat.com>
Thu, 23 Aug 2018 01:40:06 +0000 (21:40 -0400)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 10 Oct 2018 23:54:10 +0000 (09:54 +1000)
We forget to free drm in all instances of failure, and additionally also
forget to destroy the master client if the other client fails
initialization.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Cc: Karol Herbst <kherbst@redhat.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_drm.c

index 74d2283f2c28e7bb06f97856f93b610d12522a04..905956809d212722060c8886caeb5b1de9bd59a5 100644 (file)
@@ -538,11 +538,11 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 
        ret = nouveau_cli_init(drm, "DRM-master", &drm->master);
        if (ret)
-               return ret;
+               goto fail_alloc;
 
        ret = nouveau_cli_init(drm, "DRM", &drm->client);
        if (ret)
-               return ret;
+               goto fail_master;
 
        dev->irq_enabled = true;
 
@@ -605,7 +605,9 @@ fail_bios:
 fail_ttm:
        nouveau_vga_fini(drm);
        nouveau_cli_fini(&drm->client);
+fail_master:
        nouveau_cli_fini(&drm->master);
+fail_alloc:
        kfree(drm);
        return ret;
 }