public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@tieto.com>
To: Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] android/health: Fix NULL dereference
Date: Wed, 20 Aug 2014 12:02:41 +0200	[thread overview]
Message-ID: <2064054.lsmHskdC9y@leonov> (raw)
In-Reply-To: <1408518123-30621-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Wednesday 20 of August 2014 10:02:03 Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> In a case get_app(), get_device(), get_channel() fail prevent
> dereference of NULL pointer. Fixes clang warnings:
> ...
> android/health.c:1980:15: warning: Access to field 'dev' results in a
> dereference of a null pointer (loaded from variable 'channel')
>         queue_remove(channel->dev->channels, channel);
>                      ^~~~~~~~~~~~
> 1 warning generated.
> ...
> ---
>  android/health.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/android/health.c b/android/health.c
> index c8af90e..665482e 100644
> --- a/android/health.c
> +++ b/android/health.c
> @@ -1931,15 +1931,15 @@ static void bt_health_connect_channel(const void
> *buf, uint16_t len)
> 
>  	app = get_app(cmd->app_id);
>  	if (!app)
> -		goto fail;
> +		goto send_rsp;
> 
>  	dev = get_device(app, cmd->bdaddr);
>  	if (!dev)
> -		goto fail;
> +		goto send_rsp;
> 
>  	channel = get_channel(app, cmd->mdep_index, dev);
>  	if (!channel)
> -		goto fail;
> +		goto send_rsp;
> 
>  	if (!queue_length(dev->channels)) {
>  		if (channel->type != CHANNEL_TYPE_RELIABLE) {
> @@ -1979,6 +1979,8 @@ static void bt_health_connect_channel(const void *buf,
> uint16_t len) fail:
>  	queue_remove(channel->dev->channels, channel);
>  	free_health_channel(channel);
> +
> +send_rsp:
>  	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_HEALTH,
>  			HAL_OP_HEALTH_CONNECT_CHANNEL, HAL_STATUS_FAILED);
>  }

Applied, thanks.

-- 
BR
Szymon Janc

  reply	other threads:[~2014-08-20 10:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20  7:02 [PATCH] android/health: Fix NULL dereference Andrei Emeltchenko
2014-08-20 10:02 ` Szymon Janc [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-06-27 14:07 Andrei Emeltchenko
2014-06-27 14:12 ` Szymon Janc

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=2064054.lsmHskdC9y@leonov \
    --to=szymon.janc@tieto.com \
    --cc=Andrei.Emeltchenko.news@gmail.com \
    --cc=linux-bluetooth@vger.kernel.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