diff mbox

[v2] drm: don't double-free on driver load error

Message ID 1386254569-28477-1-git-send-email-imirkin@alum.mit.edu (mailing list archive)
State Accepted
Headers show

Commit Message

Ilia Mirkin Dec. 5, 2013, 2:42 p.m. UTC
All instances of drm_dev_register are followed by drm_dev_free on
failure. Don't free dev->control/render/primary on failure, as they will
be freed by drm_dev_free since commit 8f6599da8e (drm: delay minor
destruction to drm_dev_free()). Instead unplug them.

Reported-by: Bruno Prémont <bonbons@linux-vserver.org>
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
---

v2: use drm_unplug_minor instead of just removing the puts, as suggested by
    David Herrman.

 drivers/gpu/drm/drm_stub.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Bruno Prémont Dec. 5, 2013, 3:01 p.m. UTC | #1
Hi Ilia,

On Thu,  5 Dec 2013 09:42:49 -0500 Ilia Mirkin wrote:
> All instances of drm_dev_register are followed by drm_dev_free on
> failure. Don't free dev->control/render/primary on failure, as they will
> be freed by drm_dev_free since commit 8f6599da8e (drm: delay minor
> destruction to drm_dev_free()). Instead unplug them.

This patch prevents the reported GPF for 3.13-rc2 on my MBA2,1
with GeForce 9400M.

So
  Reported-and-tested-by: Bruno Prémont <bonbons@linux-vserver.org>


Resulting dmesg is:
...
[   34.179136] ACPI Warning: \_SB_.PCI0.IXVE.IGPU._DSM: Argument #4 type mismatch - Found [Integer], ACPI requires [Package] (20131115/nsarguments-95)
[   34.179315] ACPI Warning: \_SB_.PCI0.IXVE.IGPU._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20131115/nsarguments-95)
[   34.179478] checking generic (80010000 640000) vs hw (80000000 10000000)
[   34.179481] fb: conflicting fb hw usage nouveaufb vs EFI VGA - removing generic driver
[   34.179587] Console: switching to colour dummy device 80x25
[   34.179841] nouveau 0000:02:00.0: enabling device (0006 -> 0007)
[   34.181330] ACPI: PCI Interrupt Link [LGPU] enabled at IRQ 16
[   34.181549] [drm] hdmi device  not found 2 0 1
[   34.182041] nouveau  [  DEVICE][0000:02:00.0] BOOT0  : 0x0ac800b1
[   34.182044] nouveau  [  DEVICE][0000:02:00.0] Chipset: MCP79/MCP7A (NVAC)
[   34.182047] nouveau  [  DEVICE][0000:02:00.0] Family : NV50
[   34.189313] nouveau  [   VBIOS][0000:02:00.0] checking PRAMIN for image...
[   34.247351] nouveau  [   VBIOS][0000:02:00.0] ... appears to be valid
[   34.247355] nouveau  [   VBIOS][0000:02:00.0] using image from PRAMIN
[   34.247521] nouveau  [   VBIOS][0000:02:00.0] BIT signature found
[   34.247525] nouveau  [   VBIOS][0000:02:00.0] version 62.79.47.00.01
[   34.269748] nouveau 0000:02:00.0: irq 42 for MSI/MSI-X
[   34.269816] nouveau  [     PMC][0000:02:00.0] MSI interrupts enabled
[   34.269956] nouveau  [     PFB][0000:02:00.0] RAM type: stolen system memory
[   34.269963] nouveau  [     PFB][0000:02:00.0] RAM size: 256 MiB
[   34.269969] nouveau  [     PFB][0000:02:00.0]    ZCOMP: 0 tags
[   34.328924] nouveau  [  PTHERM][0000:02:00.0] FAN control: none / external
[   34.328935] nouveau  [  PTHERM][0000:02:00.0] fan management: automatic
[   34.328939] nouveau  [  PTHERM][0000:02:00.0] internal sensor: yes
[   34.328949] nouveau  [     CLK][0000:02:00.0] 03: core 100 MHz shader 200 MHz 
[   34.328954] nouveau  [     CLK][0000:02:00.0] 05: core 150 MHz shader 300 MHz 
[   34.328959] nouveau  [     CLK][0000:02:00.0] 0e: core 300 MHz shader 600 MHz 
[   34.328964] nouveau  [     CLK][0000:02:00.0] 0f: core 350 MHz shader 800 MHz 
[   34.328978] nouveau E[     CLK][0000:02:00.0] 17 freq unknown
[   34.328980] nouveau E[     CLK][0000:02:00.0] init failed, -22
[   34.328983] nouveau E[     DRM] failed to create 0x80000080, -22
[   34.331106] nouveau: probe of 0000:02:00.0 failed with error -22

(the probe failure being fixed by commit mentioned earlier in this thread)

Thanks for the fix,
Bruno

> Reported-by: Bruno Prémont <bonbons@linux-vserver.org>
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
> 
> v2: use drm_unplug_minor instead of just removing the puts, as suggested by
>     David Herrman.
> 
>  drivers/gpu/drm/drm_stub.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index f53d524..66dd3a0 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -566,11 +566,11 @@ err_unload:
>  	if (dev->driver->unload)
>  		dev->driver->unload(dev);
>  err_primary_node:
> -	drm_put_minor(dev->primary);
> +	drm_unplug_minor(dev->primary);
>  err_render_node:
> -	drm_put_minor(dev->render);
> +	drm_unplug_minor(dev->render);
>  err_control_node:
> -	drm_put_minor(dev->control);
> +	drm_unplug_minor(dev->control);
>  err_agp:
>  	if (dev->driver->bus->agp_destroy)
>  		dev->driver->bus->agp_destroy(dev);
David Herrmann Dec. 5, 2013, 3:53 p.m. UTC | #2
Hi

On Thu, Dec 5, 2013 at 3:42 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> All instances of drm_dev_register are followed by drm_dev_free on
> failure. Don't free dev->control/render/primary on failure, as they will
> be freed by drm_dev_free since commit 8f6599da8e (drm: delay minor
> destruction to drm_dev_free()). Instead unplug them.
>
> Reported-by: Bruno Prémont <bonbons@linux-vserver.org>
> Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
> ---

Thanks, looks good now:

Reviewed-by: David Herrmann <dh.herrmann@gmail.com>

Thanks
David

> v2: use drm_unplug_minor instead of just removing the puts, as suggested by
>     David Herrman.
>
>  drivers/gpu/drm/drm_stub.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index f53d524..66dd3a0 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -566,11 +566,11 @@ err_unload:
>         if (dev->driver->unload)
>                 dev->driver->unload(dev);
>  err_primary_node:
> -       drm_put_minor(dev->primary);
> +       drm_unplug_minor(dev->primary);
>  err_render_node:
> -       drm_put_minor(dev->render);
> +       drm_unplug_minor(dev->render);
>  err_control_node:
> -       drm_put_minor(dev->control);
> +       drm_unplug_minor(dev->control);
>  err_agp:
>         if (dev->driver->bus->agp_destroy)
>                 dev->driver->bus->agp_destroy(dev);
> --
> 1.8.3.2
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index f53d524..66dd3a0 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -566,11 +566,11 @@  err_unload:
 	if (dev->driver->unload)
 		dev->driver->unload(dev);
 err_primary_node:
-	drm_put_minor(dev->primary);
+	drm_unplug_minor(dev->primary);
 err_render_node:
-	drm_put_minor(dev->render);
+	drm_unplug_minor(dev->render);
 err_control_node:
-	drm_put_minor(dev->control);
+	drm_unplug_minor(dev->control);
 err_agp:
 	if (dev->driver->bus->agp_destroy)
 		dev->driver->bus->agp_destroy(dev);