diff options
author | Andrei Emeltchenko <andrei.emeltchenko@intel.com> | 2014-01-31 16:18:47 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2014-02-02 07:43:52 -0800 |
commit | 014471cae859a34591dd1f768712aaf14788ebd2 (patch) | |
tree | 08741f143769e2c18809353cc6da609d5e7bc1d2 /android/hal-audio.c | |
parent | d8beaba79f149204ba9b1c8e845816a2fd1ba9ef (diff) | |
download | bluez-014471cae859a34591dd1f768712aaf14788ebd2.tar.gz |
android/hal-audio: Do not allocate memory if fd < 0
Fixes memory leak when returning bad fd we still allocate memory which
is not freed in the caller function audio_open_output_stream().
Diffstat (limited to 'android/hal-audio.c')
-rw-r--r-- | android/hal-audio.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/android/hal-audio.c b/android/hal-audio.c index 35bafe77e..a6347afea 100644 --- a/android/hal-audio.c +++ b/android/hal-audio.c @@ -637,6 +637,9 @@ static int audio_ipc_cmd(uint8_t service_id, uint8_t opcode, uint16_t len, break; } } + + if (*fd < 0) + goto failed; } if (rsp_len) @@ -713,7 +716,6 @@ static int ipc_open_stream_cmd(uint8_t endpoint_id, uint16_t *mtu, int *fd, result = audio_ipc_cmd(AUDIO_SERVICE_ID, AUDIO_OP_OPEN_STREAM, sizeof(cmd), &cmd, &rsp_len, rsp, fd); - if (result == AUDIO_STATUS_SUCCESS) { size_t buf_len = sizeof(struct audio_preset) + rsp->preset[0].len; |