Commit 1e2bd5f5 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Dave Airlie

drm/nouveau: fixup fbcon failure paths

Add missing calls, and fix a leak from forgetting to call the unpin function.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
Acked-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 198c14a0
...@@ -289,16 +289,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -289,16 +289,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM); ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to pin fb: %d\n", ret); NV_ERROR(drm, "failed to pin fb: %d\n", ret);
nouveau_bo_ref(NULL, &nvbo); goto out_unref;
goto out;
} }
ret = nouveau_bo_map(nvbo); ret = nouveau_bo_map(nvbo);
if (ret) { if (ret) {
NV_ERROR(drm, "failed to map fb: %d\n", ret); NV_ERROR(drm, "failed to map fb: %d\n", ret);
nouveau_bo_unpin(nvbo); goto out_unpin;
nouveau_bo_ref(NULL, &nvbo);
goto out;
} }
chan = nouveau_nofbaccel ? NULL : drm->channel; chan = nouveau_nofbaccel ? NULL : drm->channel;
...@@ -316,13 +313,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -316,13 +313,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
info = framebuffer_alloc(0, &pdev->dev); info = framebuffer_alloc(0, &pdev->dev);
if (!info) { if (!info) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_unref; goto out_unlock;
} }
ret = fb_alloc_cmap(&info->cmap, 256, 0); ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret) { if (ret) {
ret = -ENOMEM; ret = -ENOMEM;
goto out_unref; framebuffer_release(info);
goto out_unlock;
} }
info->par = fbcon; info->par = fbcon;
...@@ -337,7 +335,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -337,7 +335,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
fbcon->helper.fbdev = info; fbcon->helper.fbdev = info;
strcpy(info->fix.id, "nouveaufb"); strcpy(info->fix.id, "nouveaufb");
if (nouveau_nofbaccel) if (!chan)
info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED; info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED;
else else
info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA |
...@@ -383,8 +381,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ...@@ -383,8 +381,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper,
vga_switcheroo_client_fb_set(dev->pdev, info); vga_switcheroo_client_fb_set(dev->pdev, info);
return 0; return 0;
out_unref: out_unlock:
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
if (chan)
nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma);
out_unpin:
nouveau_bo_unpin(nvbo);
out_unref:
nouveau_bo_ref(NULL, &nvbo);
out: out:
return ret; return ret;
} }
...@@ -413,6 +417,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon) ...@@ -413,6 +417,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon)
if (nouveau_fb->nvbo) { if (nouveau_fb->nvbo) {
nouveau_bo_unmap(nouveau_fb->nvbo); nouveau_bo_unmap(nouveau_fb->nvbo);
nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma); nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma);
nouveau_bo_unpin(nouveau_fb->nvbo);
drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem); drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem);
nouveau_fb->nvbo = NULL; nouveau_fb->nvbo = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment