From: Marcel Holtmann <marcel@holtmann.org>
To: "Purdila, Octavian" <octavian.purdila@intel.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: silence lockdep warning
Date: Sat, 21 Jan 2012 20:28:10 +0100 [thread overview]
Message-ID: <1327174090.1955.58.camel@aeonflux> (raw)
In-Reply-To: <CAE1zotLwpoq-6kKpsCf_KWY+AbjTa9Pd4m_v_wKX6JdmJ9O8nA@mail.gmail.com>
Hi Octavian,
> >> >> +void bt_sock_reclassify_lock(struct sock *sk, int proto)
> >> >> {
> >> >> - struct sock *sk = sock->sk;
> >> >> -
> >> >> if (!sk)
> >> >> return;
> >> >
> >> > Why are we keeping the !sk check here if we already hand in the sk. It
> >> > is most likely checked by the caller already.
> >> >
> >>
> >> In rfcomm_sock_create (called from bt_sock_create) sock->sk can be set
> >> to NULL so I think we should keep the check.
> >
> > it has been too long since I looked at this part of the code. You need
> > to walk me through it why this is still true.
> >
>
> Hi Marcel,
>
> In bt_sock_create we have:
>
> if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
> err = bt_proto[proto]->create(net, sock, proto, kern);
> bt_sock_reclassify_lock(sock->sk, proto);
>
> and create can be rfcomm_sock_create where we have
>
> sk = rfcomm_sock_alloc(net, sock, protocol, GFP_ATOMIC);
> if (!sk)
> return -ENOMEM;
>
> So after calling ->create() sock->sk can be NULL and thus we can call
> bt_sock_reclassify with a NULL parameter.
so instead of keep checking sock->sk multiple times in different places,
why not actually check the error from bt_proto[]->create() and skip the
reclassify_lock call.
And if we wanna be really paranoid, then lets add a BUG_ON for sk so we
get some nice backtraces if we have a wrongful caller.
Regards
Marcel
next prev parent reply other threads:[~2012-01-21 19:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-19 17:19 [PATCH] Bluetooth: silence lockdep warning Octavian Purdila
2012-01-21 16:44 ` Marcel Holtmann
2012-01-21 17:30 ` Purdila, Octavian
2012-01-21 18:29 ` Marcel Holtmann
2012-01-21 18:44 ` Purdila, Octavian
2012-01-21 19:28 ` Marcel Holtmann [this message]
2012-01-21 19:51 ` Purdila, Octavian
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=1327174090.1955.58.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=octavian.purdila@intel.com \
/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