All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH BlueZ] android/AVDTP: Duplicate fd passed to avdtp_new
Date: Fri, 20 Dec 2013 12:08:22 +0200	[thread overview]
Message-ID: <52B41716.6010804@linux.intel.com> (raw)
In-Reply-To: <1387533387-6724-1-git-send-email-luiz.dentz@gmail.com>

Hi Luiz,

On 20.12.2013 11:56, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This use dup to create a new fd to be used by AVDTP session leaving the
> caller free to close the original fd. Note that even if the caller
> decides to keep the original fd it will still be notified when
> avdtp_shutdown is called since it uses shutdown.
> ---
>   android/a2dp.c  | 1 -
>   android/avdtp.c | 7 ++++++-
>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/android/a2dp.c b/android/a2dp.c
> index 9087c62..b7bb8d2 100644
> --- a/android/a2dp.c
> +++ b/android/a2dp.c
> @@ -150,7 +150,6 @@ static void signaling_connect_cb(GIOChannel *chan, GError *err,
>   		return;
>   	}
>   
> -	g_io_channel_set_close_on_unref(chan, FALSE);
>   	fd = g_io_channel_unix_get_fd(chan);
>   
>   	/* FIXME: Add proper version */
> diff --git a/android/avdtp.c b/android/avdtp.c
> index 353316c..ec78cc6 100644
> --- a/android/avdtp.c
> +++ b/android/avdtp.c
> @@ -2055,9 +2055,14 @@ struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version)
>   {
>   	struct avdtp *session;
>   	GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL;
> +	int new_fd;
> +
> +	new_fd = dup(fd);
> +	if (new_fd < 0)
> +		return NULL;
  You are returning NULL here, but not checking at
  static void signaling_connect_cb(...)
         dev->session = avdtp_new(fd, imtu, omtu, 0x0100);

>   
>   	session = g_new0(struct avdtp, 1);
> -	session->io = g_io_channel_unix_new(fd);
> +	session->io = g_io_channel_unix_new(new_fd);
>   	session->version = version;
>   	session->imtu = imtu;
>   	session->omtu = omtu;

Regards,
Ravi.

  reply	other threads:[~2013-12-20 10:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20  9:56 [PATCH BlueZ] android/AVDTP: Duplicate fd passed to avdtp_new Luiz Augusto von Dentz
2013-12-20 10:08 ` Ravi kumar Veeramally [this message]
2013-12-20 13:16 ` Marcel Holtmann
2013-12-20 13:44   ` Luiz Augusto von Dentz
2013-12-20 13:52     ` Marcel Holtmann
2013-12-20 14:09       ` Luiz Augusto von Dentz
2013-12-20 14:39         ` Marcel Holtmann
2013-12-20 15:40           ` Luiz Augusto von Dentz

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=52B41716.6010804@linux.intel.com \
    --to=ravikumar.veeramally@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.