Commit a8f81837 authored by Ben Skeggs's avatar Ben Skeggs

drm/nv50/disp: fixup error paths in crtc object creation

Reported-by: default avatarMarcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 5ace2c9d
...@@ -383,23 +383,15 @@ nv50_crtc_set_clock(struct drm_device *dev, int head, int pclk) ...@@ -383,23 +383,15 @@ nv50_crtc_set_clock(struct drm_device *dev, int head, int pclk)
static void static void
nv50_crtc_destroy(struct drm_crtc *crtc) nv50_crtc_destroy(struct drm_crtc *crtc)
{ {
struct drm_device *dev; struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
struct nouveau_crtc *nv_crtc;
if (!crtc)
return;
dev = crtc->dev;
nv_crtc = nouveau_crtc(crtc);
NV_DEBUG_KMS(dev, "\n");
drm_crtc_cleanup(&nv_crtc->base); NV_DEBUG_KMS(crtc->dev, "\n");
nouveau_bo_unmap(nv_crtc->lut.nvbo); nouveau_bo_unmap(nv_crtc->lut.nvbo);
nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
nouveau_bo_unmap(nv_crtc->cursor.nvbo); nouveau_bo_unmap(nv_crtc->cursor.nvbo);
nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
drm_crtc_cleanup(&nv_crtc->base);
kfree(nv_crtc); kfree(nv_crtc);
} }
...@@ -755,18 +747,22 @@ nv50_crtc_create(struct drm_device *dev, int index) ...@@ -755,18 +747,22 @@ nv50_crtc_create(struct drm_device *dev, int index)
if (!nv_crtc) if (!nv_crtc)
return -ENOMEM; return -ENOMEM;
nv_crtc->index = index;
nv_crtc->set_dither = nv50_crtc_set_dither;
nv_crtc->set_scale = nv50_crtc_set_scale;
nv_crtc->set_color_vibrance = nv50_crtc_set_color_vibrance;
nv_crtc->color_vibrance = 50; nv_crtc->color_vibrance = 50;
nv_crtc->vibrant_hue = 0; nv_crtc->vibrant_hue = 0;
nv_crtc->lut.depth = 0;
/* Default CLUT parameters, will be activated on the hw upon
* first mode set.
*/
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
nv_crtc->lut.r[i] = i << 8; nv_crtc->lut.r[i] = i << 8;
nv_crtc->lut.g[i] = i << 8; nv_crtc->lut.g[i] = i << 8;
nv_crtc->lut.b[i] = i << 8; nv_crtc->lut.b[i] = i << 8;
} }
nv_crtc->lut.depth = 0;
drm_crtc_init(dev, &nv_crtc->base, &nv50_crtc_funcs);
drm_crtc_helper_add(&nv_crtc->base, &nv50_crtc_helper_funcs);
drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
ret = nouveau_bo_new(dev, 4096, 0x100, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(dev, 4096, 0x100, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, &nv_crtc->lut.nvbo); 0, 0x0000, NULL, &nv_crtc->lut.nvbo);
...@@ -778,21 +774,9 @@ nv50_crtc_create(struct drm_device *dev, int index) ...@@ -778,21 +774,9 @@ nv50_crtc_create(struct drm_device *dev, int index)
nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo);
} }
if (ret) { if (ret)
kfree(nv_crtc); goto out;
return ret;
}
nv_crtc->index = index;
/* set function pointers */
nv_crtc->set_dither = nv50_crtc_set_dither;
nv_crtc->set_scale = nv50_crtc_set_scale;
nv_crtc->set_color_vibrance = nv50_crtc_set_color_vibrance;
drm_crtc_init(dev, &nv_crtc->base, &nv50_crtc_funcs);
drm_crtc_helper_add(&nv_crtc->base, &nv50_crtc_helper_funcs);
drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);
ret = nouveau_bo_new(dev, 64*64*4, 0x100, TTM_PL_FLAG_VRAM, ret = nouveau_bo_new(dev, 64*64*4, 0x100, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, &nv_crtc->cursor.nvbo); 0, 0x0000, NULL, &nv_crtc->cursor.nvbo);
...@@ -804,6 +788,12 @@ nv50_crtc_create(struct drm_device *dev, int index) ...@@ -804,6 +788,12 @@ nv50_crtc_create(struct drm_device *dev, int index)
nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo);
} }
if (ret)
goto out;
nv50_cursor_init(nv_crtc); nv50_cursor_init(nv_crtc);
return 0; out:
if (ret)
nv50_crtc_destroy(&nv_crtc->base);
return ret;
} }
...@@ -358,8 +358,11 @@ nv50_display_create(struct drm_device *dev) ...@@ -358,8 +358,11 @@ nv50_display_create(struct drm_device *dev)
dev_priv->engine.display.priv = priv; dev_priv->engine.display.priv = priv;
/* Create CRTC objects */ /* Create CRTC objects */
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++) {
nv50_crtc_create(dev, i); ret = nv50_crtc_create(dev, i);
if (ret)
return ret;
}
/* We setup the encoders from the BIOS table */ /* We setup the encoders from the BIOS table */
for (i = 0 ; i < dcb->entries; i++) { for (i = 0 ; i < dcb->entries; i++) {
......
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