Skip to content

Commit 53d2844

Browse files
committed
igo_nr: compute circular buffer ends in samples not bytes
The processing buffers' end pointers were computed by adding a byte count to sample-typed pointers, placing the end past the real buffer and letting the wrap check pass too late. Convert the byte sizes to element counts when computing the ends. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 13dd43f commit 53d2844

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/audio/igo_nr/igo_nr.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ static int igo_nr_capture_s16(struct comp_data *cd,
105105
}
106106

107107
y2 = y1;
108-
x_end = x_start + x_size;
109-
y_end = y_start + y_size;
108+
/* x_size/y_size are byte counts but the pointers are sample-typed, so
109+
* convert to element counts when computing the buffer ends; otherwise
110+
* the wrap check below allows reading/writing past the buffer
111+
*/
112+
x_end = x_start + x_size / sizeof(*x_start);
113+
y_end = y_start + y_size / sizeof(*y_start);
110114

111115
/* Deinterleave the source buffer and keeps the active channel data as input. */
112116
i = 0;
@@ -207,8 +211,12 @@ static int igo_nr_capture_s24(struct comp_data *cd,
207211
}
208212

209213
y2 = y1;
210-
x_end = x_start + x_size;
211-
y_end = y_start + y_size;
214+
/* x_size/y_size are byte counts but the pointers are sample-typed, so
215+
* convert to element counts when computing the buffer ends; otherwise
216+
* the wrap check below allows reading/writing past the buffer
217+
*/
218+
x_end = x_start + x_size / sizeof(*x_start);
219+
y_end = y_start + y_size / sizeof(*y_start);
212220

213221
/* Deinterleave the source buffer and keeps the active channel data as input. */
214222
i = 0;
@@ -308,8 +316,12 @@ static int igo_nr_capture_s32(struct comp_data *cd,
308316
}
309317

310318
y2 = y1;
311-
x_end = x_start + x_size;
312-
y_end = y_start + y_size;
319+
/* x_size/y_size are byte counts but the pointers are sample-typed, so
320+
* convert to element counts when computing the buffer ends; otherwise
321+
* the wrap check below allows reading/writing past the buffer
322+
*/
323+
x_end = x_start + x_size / sizeof(*x_start);
324+
y_end = y_start + y_size / sizeof(*y_start);
313325

314326
/* Deinterleave the source buffer and keeps the active channel data as input. */
315327
i = 0;

0 commit comments

Comments
 (0)