diff options
author | Ben Skeggs <bskeggs@redhat.com> | 2012-04-19 21:01:46 -0400 |
---|---|---|
committer | Ben Skeggs <bskeggs@redhat.com> | 2012-05-24 02:31:56 -0400 |
commit | a8f81837c506aba186b42f0c67633e85851395b1 (patch) | |
tree | 522ff28e562b4fc9eacf7d51d9f4d7a7763afdb5 /drivers/gpu | |
parent | 5ace2c9d6f5bc4600ca43fe188a33efc4c2dba79 (diff) |
drm/nv50/disp: fixup error paths in crtc object creation
Reported-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_crtc.c | 52 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nv50_display.c | 7 |
2 files changed, 26 insertions, 33 deletions
diff --git a/drivers/gpu/drm/nouveau/nv50_crtc.c b/drivers/gpu/drm/nouveau/nv50_crtc.c index 7eb3aa3b099e..97a477b3d52d 100644 --- a/drivers/gpu/drm/nouveau/nv50_crtc.c +++ b/drivers/gpu/drm/nouveau/nv50_crtc.c | |||
@@ -383,23 +383,15 @@ nv50_crtc_set_clock(struct drm_device *dev, int head, int pclk) | |||
383 | static void | 383 | static void |
384 | nv50_crtc_destroy(struct drm_crtc *crtc) | 384 | nv50_crtc_destroy(struct drm_crtc *crtc) |
385 | { | 385 | { |
386 | struct drm_device *dev; | 386 | struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc); |
387 | struct nouveau_crtc *nv_crtc; | ||
388 | |||
389 | if (!crtc) | ||
390 | return; | ||
391 | |||
392 | dev = crtc->dev; | ||
393 | nv_crtc = nouveau_crtc(crtc); | ||
394 | |||
395 | NV_DEBUG_KMS(dev, "\n"); | ||
396 | 387 | ||
397 | drm_crtc_cleanup(&nv_crtc->base); | 388 | NV_DEBUG_KMS(crtc->dev, "\n"); |
398 | 389 | ||
399 | nouveau_bo_unmap(nv_crtc->lut.nvbo); | 390 | nouveau_bo_unmap(nv_crtc->lut.nvbo); |
400 | nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); | 391 | nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); |
401 | nouveau_bo_unmap(nv_crtc->cursor.nvbo); | 392 | nouveau_bo_unmap(nv_crtc->cursor.nvbo); |
402 | nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); | 393 | nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); |
394 | drm_crtc_cleanup(&nv_crtc->base); | ||
403 | kfree(nv_crtc); | 395 | kfree(nv_crtc); |
404 | } | 396 | } |
405 | 397 | ||
@@ -755,18 +747,22 @@ nv50_crtc_create(struct drm_device *dev, int index) | |||
755 | if (!nv_crtc) | 747 | if (!nv_crtc) |
756 | return -ENOMEM; | 748 | return -ENOMEM; |
757 | 749 | ||
750 | nv_crtc->index = index; | ||
751 | nv_crtc->set_dither = nv50_crtc_set_dither; | ||
752 | nv_crtc->set_scale = nv50_crtc_set_scale; | ||
753 | nv_crtc->set_color_vibrance = nv50_crtc_set_color_vibrance; | ||
758 | nv_crtc->color_vibrance = 50; | 754 | nv_crtc->color_vibrance = 50; |
759 | nv_crtc->vibrant_hue = 0; | 755 | nv_crtc->vibrant_hue = 0; |
760 | 756 | nv_crtc->lut.depth = 0; | |
761 | /* Default CLUT parameters, will be activated on the hw upon | ||
762 | * first mode set. | ||
763 | */ | ||
764 | for (i = 0; i < 256; i++) { | 757 | for (i = 0; i < 256; i++) { |
765 | nv_crtc->lut.r[i] = i << 8; | 758 | nv_crtc->lut.r[i] = i << 8; |
766 | nv_crtc->lut.g[i] = i << 8; | 759 | nv_crtc->lut.g[i] = i << 8; |
767 | nv_crtc->lut.b[i] = i << 8; | 760 | nv_crtc->lut.b[i] = i << 8; |
768 | } | 761 | } |
769 | nv_crtc->lut.depth = 0; | 762 | |
763 | drm_crtc_init(dev, &nv_crtc->base, &nv50_crtc_funcs); | ||
764 | drm_crtc_helper_add(&nv_crtc->base, &nv50_crtc_helper_funcs); | ||
765 | drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256); | ||
770 | 766 | ||
771 | ret = nouveau_bo_new(dev, 4096, 0x100, TTM_PL_FLAG_VRAM, | 767 | ret = nouveau_bo_new(dev, 4096, 0x100, TTM_PL_FLAG_VRAM, |
772 | 0, 0x0000, NULL, &nv_crtc->lut.nvbo); | 768 | 0, 0x0000, NULL, &nv_crtc->lut.nvbo); |
@@ -778,21 +774,9 @@ nv50_crtc_create(struct drm_device *dev, int index) | |||
778 | nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); | 774 | nouveau_bo_ref(NULL, &nv_crtc->lut.nvbo); |
779 | } | 775 | } |
780 | 776 | ||
781 | if (ret) { | 777 | if (ret) |
782 | kfree(nv_crtc); | 778 | goto out; |
783 | return ret; | ||
784 | } | ||
785 | |||
786 | nv_crtc->index = index; | ||
787 | 779 | ||
788 | /* set function pointers */ | ||
789 | nv_crtc->set_dither = nv50_crtc_set_dither; | ||
790 | nv_crtc->set_scale = nv50_crtc_set_scale; | ||
791 | nv_crtc->set_color_vibrance = nv50_crtc_set_color_vibrance; | ||
792 | |||
793 | drm_crtc_init(dev, &nv_crtc->base, &nv50_crtc_funcs); | ||
794 | drm_crtc_helper_add(&nv_crtc->base, &nv50_crtc_helper_funcs); | ||
795 | drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256); | ||
796 | 780 | ||
797 | ret = nouveau_bo_new(dev, 64*64*4, 0x100, TTM_PL_FLAG_VRAM, | 781 | ret = nouveau_bo_new(dev, 64*64*4, 0x100, TTM_PL_FLAG_VRAM, |
798 | 0, 0x0000, NULL, &nv_crtc->cursor.nvbo); | 782 | 0, 0x0000, NULL, &nv_crtc->cursor.nvbo); |
@@ -804,6 +788,12 @@ nv50_crtc_create(struct drm_device *dev, int index) | |||
804 | nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); | 788 | nouveau_bo_ref(NULL, &nv_crtc->cursor.nvbo); |
805 | } | 789 | } |
806 | 790 | ||
791 | if (ret) | ||
792 | goto out; | ||
793 | |||
807 | nv50_cursor_init(nv_crtc); | 794 | nv50_cursor_init(nv_crtc); |
808 | return 0; | 795 | out: |
796 | if (ret) | ||
797 | nv50_crtc_destroy(&nv_crtc->base); | ||
798 | return ret; | ||
809 | } | 799 | } |
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index 211e5e9565ce..b526e3f61c17 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
@@ -358,8 +358,11 @@ nv50_display_create(struct drm_device *dev) | |||
358 | dev_priv->engine.display.priv = priv; | 358 | dev_priv->engine.display.priv = priv; |
359 | 359 | ||
360 | /* Create CRTC objects */ | 360 | /* Create CRTC objects */ |
361 | for (i = 0; i < 2; i++) | 361 | for (i = 0; i < 2; i++) { |
362 | nv50_crtc_create(dev, i); | 362 | ret = nv50_crtc_create(dev, i); |
363 | if (ret) | ||
364 | return ret; | ||
365 | } | ||
363 | 366 | ||
364 | /* We setup the encoders from the BIOS table */ | 367 | /* We setup the encoders from the BIOS table */ |
365 | for (i = 0 ; i < dcb->entries; i++) { | 368 | for (i = 0 ; i < dcb->entries; i++) { |