public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Forrest Zhao <forrest.zhao@intel.com>
Cc: linux-bluetooth@vger.kernel.org, forrest.zhao@gmail.com
Subject: Re: [PATCH] fix bugs in HFP HF role audio part
Date: Tue, 30 Jun 2009 10:36:10 +0300	[thread overview]
Message-ID: <20090630073610.GA23086@jh-x301> (raw)
In-Reply-To: <1246346181-25864-1-git-send-email-forrest.zhao@intel.com>

Hi Forrest,

A few comments below.

On Tue, Jun 30, 2009, Forrest Zhao wrote:
> +		debug("connection with remote BT is closed\n");

The debug function/macro already takes care of the newline character when
necessary so no need to have it in the call.

>  	if (cond & (G_IO_ERR | G_IO_HUP)) {
> +		debug("sco connection is released\n");
>  		GIOChannel *chan = gw->sco;
> -		g_io_channel_unref(chan);
>  		g_io_channel_close(chan);
>  		gw->sco = NULL;

This looks like it's working around a reference counting bug somewhere
else instead of fixing it. Probably you're doing an incorrect unref
somewhere else which means that gw->sco doesn't actually have its own ref.
Please find the right place and fix it.

>  	gw->sco = g_io_channel_ref(io);
>  
> +	g_io_add_watch(gw->sco, G_IO_ERR | G_IO_HUP | G_IO_NVAL,
> +                                (GIOFunc) sco_io_cb, dev);
>  	return 0;
>  }

Based on this it looks like the unref of gw->sco when setting it back to
NULL should be perfectly possible. So either you have an incorrect unref
somewhere else or then the removal of the unref is introducing a memory
leak.

>  	if (rfcomm) {
>  		g_io_channel_close(rfcomm);
> -		g_io_channel_unref(rfcomm);
>  		gw->rfcomm = NULL;
>  	}
>  
>  	if (sco) {
>  		g_io_channel_close(sco);
> -		g_io_channel_unref(sco);
>  		gw->sco = NULL;

Again these don't look right. If you can't unref when you clear a pointer
(set it to NULL) then you're not doing the reference counting right.

>  	g_io_channel_close(gw->sco);
> -	g_io_channel_unref(gw->sco);
>  	gw->sco = NULL;

Same here.

Johan

  reply	other threads:[~2009-06-30  7:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-30  7:16 [PATCH] fix bugs in HFP HF role audio part Forrest Zhao
2009-06-30  7:36 ` Johan Hedberg [this message]
2009-06-30  7:46 ` Martin Sucha

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=20090630073610.GA23086@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=forrest.zhao@gmail.com \
    --cc=forrest.zhao@intel.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