Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5550b517 authored by Yeleswarapu Nagaradhesh's avatar Yeleswarapu Nagaradhesh
Browse files

ASoC: wcd9xxx: fix out of bound access



Somtimes index can be more than array size of imped_index.
which can lead to out of bound access. Fix this by checking
for valid value of index.

CRs-Fixed: 2000364
Change-Id: Ie571992f7a0b8156b02e09bb3adb0f9c9a370df7
Signed-off-by: default avatarYeleswarapu Nagaradhesh <nagaradh@codeaurora.org>
parent 87905821
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -194,7 +194,7 @@ void wcd_clsh_imped_config(struct snd_soc_codec *codec, int imped, bool reset)
		return;
	}
	index = get_impedance_index(imped);
	if (index >= ARRAY_SIZE(imped_index)) {
	if (index >= (ARRAY_SIZE(imped_index) - 1)) {
		pr_debug("%s, impedance not in range = %d\n", __func__, imped);
		return;
	}