linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <andrei.emeltchenko.news@gmail.com>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: linux-bluetooth@vger.kernel.org, marcel@holtmann.org,
	gustavo@padovan.org
Subject: Re: [PATCH 2/3] Bluetooth: Replace unsafe batostr() calls with ba2str()
Date: Tue, 8 May 2012 16:49:01 +0300	[thread overview]
Message-ID: <20120508134859.GC29352@aemeltch-MOBL1> (raw)
In-Reply-To: <1336483706-1533-2-git-send-email-dh.herrmann@googlemail.com>

Hi David,

On Tue, May 08, 2012 at 03:28:25PM +0200, David Herrmann wrote:
> batostr() is not thread-safe so we _must_ use ba2str() in all un-protected
> paths (which is pretty everywhere in our source).
> 
> All places where BT_DBG() is used we call ba2str() as parameter so the
> static buffer is unused if debug is disabled during compilation and gcc
> should be clever enough to remove the buffers.
> 
> Reported-by: Johannes Berg <johannes@sipsolutions.net>
> Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
> ---
>  net/bluetooth/bnep/core.c   |    4 +++-
>  net/bluetooth/cmtp/core.c   |    3 ++-
>  net/bluetooth/hci_conn.c    |    9 ++++++---
>  net/bluetooth/hci_core.c    |   32 ++++++++++++++++++++++----------
>  net/bluetooth/hci_event.c   |   17 +++++++++++------
>  net/bluetooth/hci_sysfs.c   |   14 ++++++++++----
>  net/bluetooth/hidp/core.c   |    4 ++--
>  net/bluetooth/l2cap_core.c  |   23 ++++++++++++++---------
>  net/bluetooth/rfcomm/core.c |   15 +++++++++------
>  net/bluetooth/rfcomm/sock.c |   10 ++++++----
>  net/bluetooth/rfcomm/tty.c  |   10 +++++++---
>  net/bluetooth/sco.c         |   20 ++++++++++++++------
>  12 files changed, 106 insertions(+), 55 deletions(-)
> 
> diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
> index a779ec7..03a3cb3 100644
> --- a/net/bluetooth/bnep/core.c
> +++ b/net/bluetooth/bnep/core.c
> @@ -166,6 +166,7 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
>  static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
>  {
>  	int n;
> +	char babuf1[BDADDR_STRLEN], babuf2[BDADDR_STRLEN];

NAK in this form. You are always allocating unneeded memory.

PS: It is not OK to put extra #ifdef's as well.

Best regards 
Andrei Emeltchenko 

  reply	other threads:[~2012-05-08 13:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-08 13:28 [PATCH 1/3] Bluetooth: Introduce ba2str() David Herrmann
2012-05-08 13:28 ` [PATCH 2/3] Bluetooth: Replace unsafe batostr() calls with ba2str() David Herrmann
2012-05-08 13:49   ` Andrei Emeltchenko [this message]
2012-05-08 14:02     ` David Herrmann
2012-05-08 14:34       ` Andrei Emeltchenko
2012-05-08 13:28 ` [PATCH 3/3] Bluetooth: Remove batostr() David Herrmann
2012-05-08 14:30   ` Ulisses Furquim
2012-05-08 14:54     ` Marcel Holtmann
2012-05-08 18:11       ` Ulisses Furquim
2012-05-09  9:02         ` Andrei Emeltchenko
2012-05-09 11:17           ` Ulisses Furquim
2012-05-09 13:10             ` Gustavo Padovan

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=20120508134859.GC29352@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=dh.herrmann@googlemail.com \
    --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).