aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-07-30 11:04:32 -0400
committerBen Skeggs <bskeggs@redhat.com>2010-08-05 18:33:41 -0400
commita0d069ea2c7b81a453d258c7f60e1f61a3fcbd9f (patch)
tree5f469ffc64a86e075c04704bdaa81c0c5c970a7b /drivers/gpu
parent2b495268fc596fd474d2a2cbbc711d8bb1e11e88 (diff)
drm/nouveau: unwind on load errors
nouveau_load() just returned directly if there was an error instead of releasing resources. Signed-off-by: Dan Carpenter <error27@gmail.com> Reviewed-by: Marcin Slusarz <marcin.slusarz@gmail.com> Signed-off-by: Francisco Jerez <currojerez@riseup.net> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_state.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_state.c b/drivers/gpu/drm/nouveau/nouveau_state.c
index ee3729e7823b..cf16bfb99c71 100644
--- a/drivers/gpu/drm/nouveau/nouveau_state.c
+++ b/drivers/gpu/drm/nouveau/nouveau_state.c
@@ -739,8 +739,10 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
739 int ret; 739 int ret;
740 740
741 dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL); 741 dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
742 if (!dev_priv) 742 if (!dev_priv) {
743 return -ENOMEM; 743 ret = -ENOMEM;
744 goto err_out;
745 }
744 dev->dev_private = dev_priv; 746 dev->dev_private = dev_priv;
745 dev_priv->dev = dev; 747 dev_priv->dev = dev;
746 748
@@ -750,8 +752,10 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
750 dev->pci_vendor, dev->pci_device, dev->pdev->class); 752 dev->pci_vendor, dev->pci_device, dev->pdev->class);
751 753
752 dev_priv->wq = create_workqueue("nouveau"); 754 dev_priv->wq = create_workqueue("nouveau");
753 if (!dev_priv->wq) 755 if (!dev_priv->wq) {
754 return -EINVAL; 756 ret = -EINVAL;
757 goto err_priv;
758 }
755 759
756 /* resource 0 is mmio regs */ 760 /* resource 0 is mmio regs */
757 /* resource 1 is linear FB */ 761 /* resource 1 is linear FB */
@@ -764,7 +768,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
764 if (!dev_priv->mmio) { 768 if (!dev_priv->mmio) {
765 NV_ERROR(dev, "Unable to initialize the mmio mapping. " 769 NV_ERROR(dev, "Unable to initialize the mmio mapping. "
766 "Please report your setup to " DRIVER_EMAIL "\n"); 770 "Please report your setup to " DRIVER_EMAIL "\n");
767 return -EINVAL; 771 ret = -EINVAL;
772 goto err_wq;
768 } 773 }
769 NV_DEBUG(dev, "regs mapped ok at 0x%llx\n", 774 NV_DEBUG(dev, "regs mapped ok at 0x%llx\n",
770 (unsigned long long)mmio_start_offs); 775 (unsigned long long)mmio_start_offs);
@@ -812,7 +817,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
812 break; 817 break;
813 default: 818 default:
814 NV_INFO(dev, "Unsupported chipset 0x%08x\n", reg0); 819 NV_INFO(dev, "Unsupported chipset 0x%08x\n", reg0);
815 return -EINVAL; 820 ret = -EINVAL;
821 goto err_mmio;
816 } 822 }
817 823
818 NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n", 824 NV_INFO(dev, "Detected an NV%2x generation card (0x%08x)\n",
@@ -820,7 +826,7 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
820 826
821 ret = nouveau_remove_conflicting_drivers(dev); 827 ret = nouveau_remove_conflicting_drivers(dev);
822 if (ret) 828 if (ret)
823 return ret; 829 goto err_mmio;
824 830
825 /* Map PRAMIN BAR, or on older cards, the aperture withing BAR0 */ 831 /* Map PRAMIN BAR, or on older cards, the aperture withing BAR0 */
826 if (dev_priv->card_type >= NV_40) { 832 if (dev_priv->card_type >= NV_40) {
@@ -834,7 +840,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
834 dev_priv->ramin_size); 840 dev_priv->ramin_size);
835 if (!dev_priv->ramin) { 841 if (!dev_priv->ramin) {
836 NV_ERROR(dev, "Failed to PRAMIN BAR"); 842 NV_ERROR(dev, "Failed to PRAMIN BAR");
837 return -ENOMEM; 843 ret = -ENOMEM;
844 goto err_mmio;
838 } 845 }
839 } else { 846 } else {
840 dev_priv->ramin_size = 1 * 1024 * 1024; 847 dev_priv->ramin_size = 1 * 1024 * 1024;
@@ -842,7 +849,8 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
842 dev_priv->ramin_size); 849 dev_priv->ramin_size);
843 if (!dev_priv->ramin) { 850 if (!dev_priv->ramin) {
844 NV_ERROR(dev, "Failed to map BAR0 PRAMIN.\n"); 851 NV_ERROR(dev, "Failed to map BAR0 PRAMIN.\n");
845 return -ENOMEM; 852 ret = -ENOMEM;
853 goto err_mmio;
846 } 854 }
847 } 855 }
848 856
@@ -857,9 +865,21 @@ int nouveau_load(struct drm_device *dev, unsigned long flags)
857 /* For kernel modesetting, init card now and bring up fbcon */ 865 /* For kernel modesetting, init card now and bring up fbcon */
858 ret = nouveau_card_init(dev); 866 ret = nouveau_card_init(dev);
859 if (ret) 867 if (ret)
860 return ret; 868 goto err_ramin;
861 869
862 return 0; 870 return 0;
871
872err_ramin:
873 iounmap(dev_priv->ramin);
874err_mmio:
875 iounmap(dev_priv->mmio);
876err_wq:
877 destroy_workqueue(dev_priv->wq);
878err_priv:
879 kfree(dev_priv);
880 dev->dev_private = NULL;
881err_out:
882 return ret;
863} 883}
864 884
865void nouveau_lastclose(struct drm_device *dev) 885void nouveau_lastclose(struct drm_device *dev)