From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fujitsu-laptop: driver [un]registration fixes
Date: Mon, 21 Dec 2009 14:46:32 -0800 [thread overview]
Message-ID: <200912211446.32380.dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <200912212232.nBLMWe5r016214@turbo.physics.adelaide.edu.au>
Hi Jonathan,
On Monday 21 December 2009 02:32:40 pm Jonathan Woithe wrote:
> Hi Dmitry
>
> > On Wed, Jul 29, 2009 at 10:15:33PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > > @@ -722,22 +722,22 @@ static int acpi_fujitsu_add(struct acpi_
> > >
> > > return result;
> > >
> > > -end:
> > > +err_unregister_input_dev:
> > > + input_unregister_device(input);
> > > err_free_input_dev:
> > > input_free_device(input);
> > > err_stop:
> >
> > Just noticed it scanning ACPI list. You must not use input_free_device()
> > after calling input_unregister_device() since unregister likely drops the
> > last reference to the device and it will get freed by input core.
>
> So what's the correct way to deal with that in this case? Something like
>
> -end:
> +err_unregister_input_dev:
> + input_unregister_device(input);
> + goto err_stop;
> err_free_input_dev:
> input_free_device(input);
> err_stop:
>
> (with a short comment to explain the goto) would circumvent the problem but
> it looks ugly (at least to my eyes - I've never really liked "goto"s :-) ).
Just do "input = NULL;" after calling input_unregister_device() -
input_free_device() is like kfree() and will happily ignore passed NULL
pointers.
Or rearrange the code to register device last, when everything is ready.
>
> > For polled input devices you need to use both unregister and free though
> > because polled device structure is not refcounted (but underlying input
> > device is).
>
> This isn't a polled input device AFAIK so this doesn't apply here, right?
Right, it was more of a general statement so I don't get bunch of patches
removing input_free_polled_device() after calls to
input_unregister_polled_device() ;)
--
Dmitry
next prev parent reply other threads:[~2009-12-21 22:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 20:15 [PATCH] fujitsu-laptop: driver [un]registration fixes Bartlomiej Zolnierkiewicz
2009-07-30 7:45 ` Jonathan Woithe
2009-07-30 7:45 ` Jonathan Woithe
2009-12-21 18:03 ` Dmitry Torokhov
2009-12-21 22:32 ` Jonathan Woithe
2009-12-21 22:32 ` Jonathan Woithe
2009-12-21 22:46 ` Dmitry Torokhov [this message]
2010-01-05 16:46 ` Bartlomiej Zolnierkiewicz
2010-01-05 19:14 ` Dmitry Torokhov
2010-01-05 22:03 ` Jonathan Woithe
2010-01-05 22:03 ` Jonathan Woithe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200912211446.32380.dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=bzolnier@gmail.com \
--cc=jwoithe@physics.adelaide.edu.au \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.