From: Peter Hurley <peter@hurleysoftware.com>
To: Gianluca Anzolin <gianluca@sottospazio.it>
Cc: gustavo@padovan.org, linux-bluetooth@vger.kernel.org,
marcel@holtmann.org
Subject: Re: [PATCH 8/8] Add module_put in rfcomm_dev_add error path
Date: Wed, 17 Jul 2013 11:20:29 -0400 [thread overview]
Message-ID: <51E6B63D.8000709@hurleysoftware.com> (raw)
In-Reply-To: <1373661649-1385-8-git-send-email-gianluca@sottospazio.it>
On 07/12/2013 04:40 PM, Gianluca Anzolin wrote:
> rfcomm_dev_add doesn't call module_put() in its error path when it took a
> reference.
Good catch.
> Fix by always calling __module_get() and module_put() in the error path.
>
> Signed-off-by: Gianluca Anzolin <gianluca@sottospazio.it>
> ---
> net/bluetooth/rfcomm/tty.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
> index 7bc603a..40288c3 100644
> --- a/net/bluetooth/rfcomm/tty.c
> +++ b/net/bluetooth/rfcomm/tty.c
> @@ -357,11 +357,11 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
>
> rfcomm_dlc_unlock(dlc);
>
> +out:
> /* It's safe to call __module_get() here because socket already
> holds reference to this module. */
> __module_get(THIS_MODULE);
>
> -out:
> spin_unlock(&rfcomm_dev_lock);
>
> if (err < 0)
Is it possible to reverse the order-of-operations here:
spin_unlock(&rfcomm_dev_lock);
__module_get(THIS_MODULE);
Then the out: label could be moved to the function exit as noted below.
The rfcomm_dev_lock use here is what creates the mess in rfcomm_dev_state_change().
Anyone know why the rfcomm_dev_lock critical section is so ridiculously large
here? Does it really protect the module count??
> @@ -386,6 +386,7 @@ out:
> return dev->id;
>
> free:
> + module_put(THIS_MODULE);
out:
spin_unlock(&rfcomm_dev_lock);
> kfree(dev);
> return err;
> }
>
next prev parent reply other threads:[~2013-07-17 15:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-12 20:40 [PATCH 1/8] Take proper tty references in net/bluetooth/rfcomm/tty.c Gianluca Anzolin
2013-07-12 20:40 ` [PATCH 2/8] Move functions before the definition of rfcomm_port_ops Gianluca Anzolin
2013-07-16 15:14 ` Peter Hurley
2013-07-12 20:40 ` [PATCH 3/8] Move device initialization and shutdown to tty_port_operations Gianluca Anzolin
2013-07-16 20:48 ` Peter Hurley
2013-07-20 7:10 ` Gianluca Anzolin
2013-07-20 14:11 ` Peter Hurley
2013-07-21 8:08 ` Gianluca Anzolin
2013-07-21 17:04 ` Peter Hurley
2013-07-21 17:31 ` Gianluca Anzolin
2013-07-12 20:40 ` [PATCH 4/8] Move tty initialization and cleanup out of open/close Gianluca Anzolin
2013-07-16 19:07 ` Peter Hurley
2013-07-12 20:40 ` [PATCH 5/8] Use the tty_port_* functions in tty_open/tty_close/tty_hangup Gianluca Anzolin
2013-07-16 20:51 ` Peter Hurley
2013-07-17 8:03 ` Gianluca Anzolin
2013-07-12 20:40 ` [PATCH 6/8] Fix the reference counting of tty_port Gianluca Anzolin
2013-07-17 14:02 ` Peter Hurley
2013-07-17 17:05 ` Gianluca Anzolin
2013-07-17 18:10 ` Peter Hurley
2013-07-18 12:45 ` Peter Hurley
2013-07-18 14:13 ` Gianluca Anzolin
2013-07-18 15:19 ` Peter Hurley
2013-07-12 20:40 ` [PATCH 7/8] Avoid a circular dependency between dev and dev->dlc Gianluca Anzolin
2013-07-12 20:40 ` [PATCH 8/8] Add module_put in rfcomm_dev_add error path Gianluca Anzolin
2013-07-17 15:20 ` Peter Hurley [this message]
2013-07-16 14:53 ` [PATCH 1/8] Take proper tty references in net/bluetooth/rfcomm/tty.c Peter Hurley
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=51E6B63D.8000709@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gianluca@sottospazio.it \
--cc=gustavo@padovan.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).