drm/xe: Do not forget to drm_dev_put() in xe_pci_probe()
authorGustavo Sousa <gustavo.sousa@intel.com>
Fri, 19 May 2023 19:48:02 +0000 (16:48 -0300)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:33:53 +0000 (18:33 -0500)
The function drm_dev_put() should also be called if xe_device_probe()
fails.

v2:
  - Improve commit message. (Lucas)

Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Link: https://lore.kernel.org/r/20230519194802.578182-1-gustavo.sousa@intel.com
Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_pci.c

index f0d0e999aa56f9b1a5f1dec680bfabe0217df432..c7184e49b10b47cd8476c9eb618535ba5c160717 100644 (file)
@@ -614,10 +614,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        subplatform_desc = find_subplatform(xe, desc);
 
        err = xe_info_init(xe, desc, subplatform_desc);
-       if (err) {
-               drm_dev_put(&xe->drm);
-               return err;
-       }
+       if (err)
+               goto err_drm_put;
 
        drm_dbg(&xe->drm, "%s %s %04x:%04x dgfx:%d gfx:%s (%d.%02d) media:%s (%d.%02d) dma_m_s:%d tc:%d",
                desc->platform_name,
@@ -640,10 +638,8 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        pci_set_drvdata(pdev, xe);
        err = pci_enable_device(pdev);
-       if (err) {
-               drm_dev_put(&xe->drm);
-               return err;
-       }
+       if (err)
+               goto err_drm_put;
 
        pci_set_master(pdev);
 
@@ -651,14 +647,20 @@ static int xe_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                drm_dbg(&xe->drm, "can't enable MSI");
 
        err = xe_device_probe(xe);
-       if (err) {
-               pci_disable_device(pdev);
-               return err;
-       }
+       if (err)
+               goto err_pci_disable;
 
        xe_pm_runtime_init(xe);
 
        return 0;
+
+err_pci_disable:
+       pci_disable_device(pdev);
+
+err_drm_put:
+       drm_dev_put(&xe->drm);
+
+       return err;
 }
 
 static void xe_pci_shutdown(struct pci_dev *pdev)