diff mbox series

drm/i915: Fix error handling if driver creation fails during probe

Message ID 20230601173804.557756-1-matthew.d.roper@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Fix error handling if driver creation fails during probe | expand

Commit Message

Matt Roper June 1, 2023, 5:38 p.m. UTC
If i915_driver_create() fails to create a valid 'i915' object, we
should just disable the PCI device and return immediately without trying
to call i915_probe_error() that relies on a valid i915 pointer.

Fixes: 12e6f6dc78e4 ("drm/i915/display: Handle GMD_ID identification in display code")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/i915/i915_driver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Gustavo Sousa June 1, 2023, 6:12 p.m. UTC | #1
Quoting Matt Roper (2023-06-01 14:38:04-03:00)
>If i915_driver_create() fails to create a valid 'i915' object, we
>should just disable the PCI device and return immediately without trying
>to call i915_probe_error() that relies on a valid i915 pointer.
>
>Fixes: 12e6f6dc78e4 ("drm/i915/display: Handle GMD_ID identification in display code")
>Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
>Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>

>---
> drivers/gpu/drm/i915/i915_driver.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
>index c3ab5c32d492..5c3fc57cc4fe 100644
>--- a/drivers/gpu/drm/i915/i915_driver.c
>+++ b/drivers/gpu/drm/i915/i915_driver.c
>@@ -762,8 +762,8 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> 
>         i915 = i915_driver_create(pdev, ent);
>         if (IS_ERR(i915)) {
>-                ret = PTR_ERR(i915);
>-                goto out_pci_disable;
>+                pci_disable_device(pdev);
>+                return PTR_ERR(i915);
>         }
> 
>         ret = i915_driver_early_probe(i915);
>-- 
>2.40.1
>
Matt Roper June 5, 2023, 11:09 p.m. UTC | #2
On Thu, Jun 01, 2023 at 03:12:42PM -0300, Gustavo Sousa wrote:
> Quoting Matt Roper (2023-06-01 14:38:04-03:00)
> >If i915_driver_create() fails to create a valid 'i915' object, we
> >should just disable the PCI device and return immediately without trying
> >to call i915_probe_error() that relies on a valid i915 pointer.
> >
> >Fixes: 12e6f6dc78e4 ("drm/i915/display: Handle GMD_ID identification in display code")
> >Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> >Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> 
> Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com>

Applied to drm-intel-next.  Thanks for the review.


Matt

> 
> >---
> > drivers/gpu/drm/i915/i915_driver.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
> >index c3ab5c32d492..5c3fc57cc4fe 100644
> >--- a/drivers/gpu/drm/i915/i915_driver.c
> >+++ b/drivers/gpu/drm/i915/i915_driver.c
> >@@ -762,8 +762,8 @@ int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> > 
> >         i915 = i915_driver_create(pdev, ent);
> >         if (IS_ERR(i915)) {
> >-                ret = PTR_ERR(i915);
> >-                goto out_pci_disable;
> >+                pci_disable_device(pdev);
> >+                return PTR_ERR(i915);
> >         }
> > 
> >         ret = i915_driver_early_probe(i915);
> >-- 
> >2.40.1
> >
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_driver.c b/drivers/gpu/drm/i915/i915_driver.c
index c3ab5c32d492..5c3fc57cc4fe 100644
--- a/drivers/gpu/drm/i915/i915_driver.c
+++ b/drivers/gpu/drm/i915/i915_driver.c
@@ -762,8 +762,8 @@  int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	i915 = i915_driver_create(pdev, ent);
 	if (IS_ERR(i915)) {
-		ret = PTR_ERR(i915);
-		goto out_pci_disable;
+		pci_disable_device(pdev);
+		return PTR_ERR(i915);
 	}
 
 	ret = i915_driver_early_probe(i915);