Linux bluetooth development
 help / color / mirror / Atom feed
* [RFC] android/hal-audio: Fix wrong memory access
@ 2014-05-22 13:07 Andrei Emeltchenko
  2014-05-22 13:54 ` Andrzej Kaczmarek
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Andrei Emeltchenko @ 2014-05-22 13:07 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

downmix_buf is allocated to have buffer size FIXED_BUFFER_SIZE / 2, when
we access it as (int16_t *) we shall device index by 2.
---
 android/hal-audio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/android/hal-audio.c b/android/hal-audio.c
index 7305bb6..96fa5c3 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -984,7 +984,7 @@ static void downmix_to_mono(struct a2dp_stream_out *out, const uint8_t *buffer,
 	int16_t *output = (void *) out->downmix_buf;
 	size_t i;
 
-	for (i = 0; i < bytes / 2; i++) {
+	for (i = 0; i < bytes / (2 * sizeof(int16_t)); i++) {
 		int16_t l = le16_to_cpu(get_unaligned(&input[i * 2]));
 		int16_t r = le16_to_cpu(get_unaligned(&input[i * 2 + 1]));
 
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-05-27  7:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 13:07 [RFC] android/hal-audio: Fix wrong memory access Andrei Emeltchenko
2014-05-22 13:54 ` Andrzej Kaczmarek
2014-05-22 14:16   ` Andrei Emeltchenko
2014-05-22 14:21 ` Marcel Holtmann
2014-05-26 12:36   ` Andrzej Kaczmarek
2014-05-26 12:48     ` Marcel Holtmann
2014-05-26 12:59       ` Andrzej Kaczmarek
2014-05-26 13:14         ` Marcel Holtmann
2014-05-27  7:54         ` Andrei Emeltchenko
2014-05-26 12:39 ` Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox