From dc6a67eda727b063558e9ae95b05ed16110a3108 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 6 Sep 2007 07:33:06 +0000 Subject: Check for valid stream fd after trying to receive it (and not before) --- audio/pcm_bluetooth.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'audio') diff --git a/audio/pcm_bluetooth.c b/audio/pcm_bluetooth.c index 6338bc25..dd61089f 100644 --- a/audio/pcm_bluetooth.c +++ b/audio/pcm_bluetooth.c @@ -1211,15 +1211,15 @@ done: return ret; } + ret = bluetooth_recvmsg_fd(data); + if (ret < 0) + return ret; + if (data->stream.fd == -1) { SNDERR("Error while configuring device: could not acquire audio socket"); return -EINVAL; } - ret = bluetooth_recvmsg_fd(data); - if (ret < 0) - return ret; - /* It is possible there is some outstanding data in the pipe - we have to empty it */ while (recv(data->stream.fd, data->buffer, data->cfg.pkt_len, @@ -1244,6 +1244,7 @@ static int bluetooth_init(struct bluetooth_data *data, snd_pcm_stream_t stream, memset(data, 0, sizeof(struct bluetooth_data)); data->server.fd = -1; + data->stream.fd = -1; sk = socket(PF_LOCAL, SOCK_STREAM, 0); if (sk < 0) { -- cgit