Ver Fonte

qcacmn: Fix fft end bin index for Spectral report modes 0 and 1

For reports modes 0 and 1, the number of FFT bins in a detector will be 0.
We calculate end_bin_idx as start_bin_idx + num_bins - 1.
When start_bin_idx is 0 for these report modes, end_bin_idx will be -1.
Since bin indices are unsigned integers, end_bin_idx becomes a very big
value and we will try to copy unintended large number of bytes.
Fix this by forcing end_bin_idx to start_bin_idx when num_bins is 0.

Change-Id: I11e5dd673fc95a1ce3823ef977fd70c34a4ec67e
CRs-Fixed: 3096955
Shiva Krishna Pittala há 3 anos atrás
pai
commit
a9948f7e23
1 ficheiros alterados com 5 adições e 3 exclusões
  1. 5 3
      target_if/spectral/target_if_spectral_phyerr.c

+ 5 - 3
target_if/spectral/target_if_spectral_phyerr.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2011,2017-2021 The Linux Foundation. All rights reserved.
- *
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
@@ -1123,8 +1123,10 @@ target_if_populate_fft_bins_info(struct target_if_spectral *spectral,
 		}
 		dest_det_info->dest_start_bin_idx = start_bin;
 		dest_det_info->dest_end_bin_idx =
-					dest_det_info->dest_start_bin_idx +
-					num_fft_bins - 1;
+					dest_det_info->dest_start_bin_idx;
+		if (num_fft_bins > 0)
+			dest_det_info->dest_end_bin_idx += (num_fft_bins - 1);
+
 		if (dest_det_info->lb_extrabins_num) {
 			if (is_ch_width_160_or_80p80(ch_width)) {
 				dest_det_info->lb_extrabins_start_idx =