]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
drm/nouveau: fix some error-path leaks in fbcon handling code
authorMaarten Lankhorst <maarten.lankhorst@canonical.com>
Mon, 8 Jul 2013 04:50:54 +0000 (14:50 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 10 Jul 2013 00:47:28 +0000 (10:47 +1000)
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_fbcon.c

index 61fdef8eac494f638f43231e413b027c158d474c..907d20ef6d4d119f81c06fe1801edf3867f01673 100644 (file)
@@ -138,7 +138,7 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
 {
        struct nouveau_framebuffer *nouveau_fb;
        struct drm_gem_object *gem;
-       int ret;
+       int ret = -ENOMEM;
 
        gem = drm_gem_object_lookup(dev, file_priv, mode_cmd->handles[0]);
        if (!gem)
@@ -146,15 +146,19 @@ nouveau_user_framebuffer_create(struct drm_device *dev,
 
        nouveau_fb = kzalloc(sizeof(struct nouveau_framebuffer), GFP_KERNEL);
        if (!nouveau_fb)
-               return ERR_PTR(-ENOMEM);
+               goto err_unref;
 
        ret = nouveau_framebuffer_init(dev, nouveau_fb, mode_cmd, nouveau_gem_object(gem));
-       if (ret) {
-               drm_gem_object_unreference(gem);
-               return ERR_PTR(ret);
-       }
+       if (ret)
+               goto err;
 
        return &nouveau_fb->base;
+
+err:
+       kfree(nouveau_fb);
+err_unref:
+       drm_gem_object_unreference(gem);
+       return ERR_PTR(ret);
 }
 
 static const struct drm_mode_config_funcs nouveau_mode_config_funcs = {
index 9352010030e9fd6f885834aca9e81c769fa61e10..4c1bc061fae2cab668f5d5f2bd24f1ab5febbc62 100644 (file)
@@ -385,6 +385,7 @@ out_unlock:
        mutex_unlock(&dev->struct_mutex);
        if (chan)
                nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma);
+       nouveau_bo_unmap(nvbo);
 out_unpin:
        nouveau_bo_unpin(nvbo);
 out_unref: