diff mbox series

[v2] drm/i915: fix wrong error number report

Message ID 20181002092047.14705-1-andi.shyti@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2] drm/i915: fix wrong error number report | expand

Commit Message

Andi Shyti Oct. 2, 2018, 9:20 a.m. UTC
During driver load it's considered that the i915_driver_create()
function fails only in case of insufficient memory. Indeed, in
case of failure of i915_driver_create(), the load function
returns indiscriminately -ENOMEM ignoring the real cause of
failure.

In i915_driver_create() get the consistent error value from
drm_dev_init() and embed it in the pointer return value.

Signed-off-by: Andi Shyti <andi.shyti@intel.com>
---
Hi,

I did forget in the version 1 to return -ENOMEM in case of
kzalloc failure. Thanks Chris!

Andi

 drivers/gpu/drm/i915/i915_drv.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Chris Wilson Oct. 2, 2018, 11:18 a.m. UTC | #1
Quoting Andi Shyti (2018-10-02 10:20:47)
> During driver load it's considered that the i915_driver_create()
> function fails only in case of insufficient memory. Indeed, in
> case of failure of i915_driver_create(), the load function
> returns indiscriminately -ENOMEM ignoring the real cause of
> failure.

Though if it is not ENOMEM, some stern words will be addressed to
whomever at fault.
 
> In i915_driver_create() get the consistent error value from
> drm_dev_init() and embed it in the pointer return value.
> 
> Signed-off-by: Andi Shyti <andi.shyti@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Chris Wilson Oct. 2, 2018, 12:38 p.m. UTC | #2
Quoting Chris Wilson (2018-10-02 12:18:49)
> Quoting Andi Shyti (2018-10-02 10:20:47)
> > During driver load it's considered that the i915_driver_create()
> > function fails only in case of insufficient memory. Indeed, in
> > case of failure of i915_driver_create(), the load function
> > returns indiscriminately -ENOMEM ignoring the real cause of
> > failure.
> 
> Though if it is not ENOMEM, some stern words will be addressed to
> whomever at fault.
>  
> > In i915_driver_create() get the consistent error value from
> > drm_dev_init() and embed it in the pointer return value.
> > 
> > Signed-off-by: Andi Shyti <andi.shyti@intel.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

And pushed, thanks for the patch.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 1b028f429e92..193023427b40 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1627,14 +1627,16 @@  i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent)
 		(struct intel_device_info *)ent->driver_data;
 	struct intel_device_info *device_info;
 	struct drm_i915_private *i915;
+	int err;
 
 	i915 = kzalloc(sizeof(*i915), GFP_KERNEL);
 	if (!i915)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
-	if (drm_dev_init(&i915->drm, &driver, &pdev->dev)) {
+	err = drm_dev_init(&i915->drm, &driver, &pdev->dev);
+	if (err) {
 		kfree(i915);
-		return NULL;
+		return ERR_PTR(err);
 	}
 
 	i915->drm.pdev = pdev;
@@ -1683,8 +1685,8 @@  int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
 	int ret;
 
 	dev_priv = i915_driver_create(pdev, ent);
-	if (!dev_priv)
-		return -ENOMEM;
+	if (IS_ERR(dev_priv))
+		return PTR_ERR(dev_priv);
 
 	/* Disable nuclear pageflip by default on pre-ILK */
 	if (!i915_modparams.nuclear_pageflip && match_info->gen < 5)