diff mbox

drm: fix double drm_put_minor() in fail paths

Message ID 1386868059-30511-1-git-send-email-robdclark@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rob Clark Dec. 12, 2013, 5:07 p.m. UTC
If driver failed to load (for example, -EPROBE_DEFER), we'd end up doing
drm_put_minor() both from drm_dev_register() and drm_dev_free(), the
second time with a bogus pointer.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 drivers/gpu/drm/drm_stub.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Ilia Mirkin Dec. 12, 2013, 5:12 p.m. UTC | #1
On Thu, Dec 12, 2013 at 12:07 PM, Rob Clark <robdclark@gmail.com> wrote:
> If driver failed to load (for example, -EPROBE_DEFER), we'd end up doing
> drm_put_minor() both from drm_dev_register() and drm_dev_free(), the
> second time with a bogus pointer.

FYI, I sent a similar patch ~week ago that changed put_minor into
unplug_minor per David Herrmann's advice.

>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
>  drivers/gpu/drm/drm_stub.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
> index f53d524..f245d99 100644
> --- a/drivers/gpu/drm/drm_stub.c
> +++ b/drivers/gpu/drm/drm_stub.c
> @@ -567,10 +567,13 @@ err_unload:
>                 dev->driver->unload(dev);
>  err_primary_node:
>         drm_put_minor(dev->primary);
> +       dev->primary = NULL;
>  err_render_node:
>         drm_put_minor(dev->render);
> +       dev->render = NULL;
>  err_control_node:
>         drm_put_minor(dev->control);
> +       dev->control = NULL;
>  err_agp:
>         if (dev->driver->bus->agp_destroy)
>                 dev->driver->bus->agp_destroy(dev);
> --
> 1.8.4.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
Rob Clark Dec. 12, 2013, 5:17 p.m. UTC | #2
On Thu, Dec 12, 2013 at 12:12 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> On Thu, Dec 12, 2013 at 12:07 PM, Rob Clark <robdclark@gmail.com> wrote:
>> If driver failed to load (for example, -EPROBE_DEFER), we'd end up doing
>> drm_put_minor() both from drm_dev_register() and drm_dev_free(), the
>> second time with a bogus pointer.
>
> FYI, I sent a similar patch ~week ago that changed put_minor into
> unplug_minor per David Herrmann's advice.

ahh, ok.. I didn't see it, but if it fixes the same issue we can drop my patch..

BR,
-R

>>
>> Signed-off-by: Rob Clark <robdclark@gmail.com>
>> ---
>>  drivers/gpu/drm/drm_stub.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
>> index f53d524..f245d99 100644
>> --- a/drivers/gpu/drm/drm_stub.c
>> +++ b/drivers/gpu/drm/drm_stub.c
>> @@ -567,10 +567,13 @@ err_unload:
>>                 dev->driver->unload(dev);
>>  err_primary_node:
>>         drm_put_minor(dev->primary);
>> +       dev->primary = NULL;
>>  err_render_node:
>>         drm_put_minor(dev->render);
>> +       dev->render = NULL;
>>  err_control_node:
>>         drm_put_minor(dev->control);
>> +       dev->control = NULL;
>>  err_agp:
>>         if (dev->driver->bus->agp_destroy)
>>                 dev->driver->bus->agp_destroy(dev);
>> --
>> 1.8.4.2
>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index f53d524..f245d99 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -567,10 +567,13 @@  err_unload:
 		dev->driver->unload(dev);
 err_primary_node:
 	drm_put_minor(dev->primary);
+	dev->primary = NULL;
 err_render_node:
 	drm_put_minor(dev->render);
+	dev->render = NULL;
 err_control_node:
 	drm_put_minor(dev->control);
+	dev->control = NULL;
 err_agp:
 	if (dev->driver->bus->agp_destroy)
 		dev->driver->bus->agp_destroy(dev);