Linux bluetooth development
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Lucas De Marchi <lucas.demarchi@profusion.mobi>
Cc: chanyeol.park@samsung.com, linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH 2/3] Fix avrcp unregister potential crash
Date: Fri, 18 May 2012 18:08:59 +0300	[thread overview]
Message-ID: <20120518150859.GA6384@x220.P-661HNU-F1> (raw)
In-Reply-To: <CAMOw1v4bO_xYRyLReN81riFtmvUxqx_=5AC3p4D9W3yzkn2EWA@mail.gmail.com>

Hi Lucas,

On Fri, May 18, 2012, Lucas De Marchi wrote:
> >> --- a/audio/avrcp.c
> >> +++ b/audio/avrcp.c
> >> @@ -1272,8 +1272,11 @@ void avrcp_unregister(const bdaddr_t *src)
> >>
> >>       servers = g_slist_remove(servers, server);
> >>
> >> -     remove_record_from_server(server->ct_record_id);
> >> -     remove_record_from_server(server->tg_record_id);
> >> +     if (server->ct_record_id)
> >> +             remove_record_from_server(server->ct_record_id);
> >> +
> >> +     if (server->tg_record_id)
> >> +             remove_record_from_server(server->tg_record_id);
> >>
> >>       avctp_unregister(&server->src);
> >>       g_free(server);
> >
> > I don't think the commit message for this patch is truthful. If you look
> > at the code the remove_record_from_server will return ENOENT if you pass
> > it a non-existent handle. I.e. it will not crash. Please fix the commit
> > message to reflect what exactly is being fixed (i.e. an unnecessary call
> > to remove_record_from_server if there is no record handle).
> 
> Then I don't see a reason: just let remove_record_from_server() fail ?
> 
> Chan, what are you fixing here?

As discussed on IRC (and Chanyeol should really have explained this in
the commit message) handle 0 is actually the SDP server's own "master"
record. So it is plausible that weird behavior might occur if trying to
remove it. Since this is a SDP server internal detail and it doesn't
really make sense to remove it I'm thinking that
remove_record_from_server should return EINVAL if passed a 0 value.

Johan

  reply	other threads:[~2012-05-18 15:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-18  8:54 [PATCH 1/3] Fix A2DP Sink/Source recognition chanyeol.park
2012-05-18  8:54 ` [PATCH 2/3] Fix avrcp unregister potential crash chanyeol.park
2012-05-18 11:40   ` Johan Hedberg
2012-05-18 13:02     ` Lucas De Marchi
2012-05-18 15:08       ` Johan Hedberg [this message]
2012-05-18 17:31         ` Johan Hedberg
2012-05-18  8:54 ` [PATCH 3/3] Add support for AVRCP control,target role conf chanyeol.park
2012-05-18 11:38 ` [PATCH 1/3] Fix A2DP Sink/Source recognition Johan Hedberg

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=20120518150859.GA6384@x220.P-661HNU-F1 \
    --to=johan.hedberg@gmail.com \
    --cc=chanyeol.park@samsung.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=lucas.demarchi@profusion.mobi \
    /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