Linux bluetooth development
 help / color / mirror / Atom feed
From: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH 1/6] android/a2dp: Fix possible NULL dereference
Date: Wed, 4 Dec 2013 10:36:25 +0200	[thread overview]
Message-ID: <20131204083622.GA18198@aemeltch-MOBL1> (raw)
In-Reply-To: <CABBYNZKRWtCvq_yg7dT+2iJFL5rvPauiOkqYP3diCc_6TN_SkA@mail.gmail.com>

Hi Luiz,

On Tue, Dec 03, 2013 at 09:53:43PM +0200, Luiz Augusto von Dentz wrote:
> Hi Andrei,
> 
> On Tue, Dec 3, 2013 at 5:53 PM, Andrei Emeltchenko
> <Andrei.Emeltchenko.news@gmail.com> wrote:
> > From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> >
> > Since a2dp_record may return NULL, check return value. This
> > silences static analysers tools.
> > ---
> >  android/a2dp.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/android/a2dp.c b/android/a2dp.c
> > index cee4bfa..36a0714 100644
> > --- a/android/a2dp.c
> > +++ b/android/a2dp.c
> > @@ -366,9 +366,10 @@ bool bt_a2dp_register(const bdaddr_t *addr)
> >         }
> >
> >         rec = a2dp_record();
> > -       if (bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
> > +       if (!rec || bt_adapter_add_record(rec, SVC_HINT_CAPTURING) < 0) {
> 
> Usually we check the return individually, that means you do if (rec)
> and perhaps handle the error path with goto, but first make sure that
> a2dp_record can actually fail otherwise this is pointless.

It might return NULL if malloc fails, do you think that we need to change
malloc to g_malloc in sdp code. Otherwise every tools warns about NULL
dereference.

Best regards 
Andrei Emeltchenko 

>
> >                 error("Failed to register on A2DP record");
> > -               sdp_record_free(rec);
> > +               if (rec)
> > +                       sdp_record_free(rec);
> >                 g_io_channel_shutdown(server, TRUE, NULL);
> >                 g_io_channel_unref(server);
> >                 server = NULL;
> > --
> > 1.8.3.2
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 
> -- 
> Luiz Augusto von Dentz

  reply	other threads:[~2013-12-04  8:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 15:53 [PATCH 1/6] android/a2dp: Fix possible NULL dereference Andrei Emeltchenko
2013-12-03 15:53 ` [PATCH 2/6] android/pan: Remove unneeded NULL assignment Andrei Emeltchenko
2013-12-03 15:53 ` [PATCH 3/6] android/pan: Fix no return on error path Andrei Emeltchenko
2013-12-03 15:53 ` [PATCH 4/6] android/doc: Add socket-api.txt document Andrei Emeltchenko
2013-12-03 15:53 ` [PATCH 5/6] sdp: Remove dead code Andrei Emeltchenko
2013-12-03 15:53 ` [PATCH 6/6] avdtp: Remove unneeded local variable Andrei Emeltchenko
2013-12-03 19:53 ` [PATCH 1/6] android/a2dp: Fix possible NULL dereference Luiz Augusto von Dentz
2013-12-04  8:36   ` Andrei Emeltchenko [this message]
2013-12-08 15:39     ` Luiz Augusto von Dentz
2013-12-09  8:01       ` Andrei Emeltchenko

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=20131204083622.GA18198@aemeltch-MOBL1 \
    --to=andrei.emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.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