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

Commit 2675d2ab authored by Ashay Jaiswal's avatar Ashay Jaiswal
Browse files

gpio: qpnp-pin: Fix out of bound shift



UBSAN: Undefined behaviour in drivers/gpio/qpnp-pin.c:664:6
shift exponent -1 is negative
Call trace:
[<ffffffc00008ad5c>] dump_backtrace+0x0/0x1a4
[<ffffffc00008af10>] show_stack+0x10/0x1c
[<ffffffc00142ed60>] dump_stack+0x7c/0xe8
[<ffffffc0005282d0>] ubsan_epilogue+0x10/0x54
[<ffffffc000528cec>] __ubsan_handle_shift_out_of_bounds+0x12c/0x160
[<ffffffc000545b78>] _qpnp_pin_config+0x65c/0x920
[<ffffffc000546b00>] qpnp_pin_probe+0xb14/0xc44

Add check for valid dtest-line before configuring the gpio.

CRs-Fixed: 981729
Change-Id: I26c6edcd26da9cfbbf2859bf9d93477f5cb1b4f5
Signed-off-by: default avatarAshay Jaiswal <ashayj@codeaurora.org>
parent a8371783
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -648,7 +648,8 @@ static int _qpnp_pin_config(struct qpnp_pin_chip *q_chip,
			  param->output_type);

	/* input config */
	if (Q_HAVE_HW_SP(Q_PIN_CFG_DTEST_SEL, q_spec, param->dtest_sel)) {
	if (Q_HAVE_HW_SP(Q_PIN_CFG_DTEST_SEL, q_spec, param->dtest_sel)
			&& param->dtest_sel) {
		if (is_gpio_lv_mv(q_spec)) {
			q_reg_clr_set(&q_spec->regs[Q_REG_I_DIG_IN_CTL],
					Q_REG_LV_MV_DTEST_SEL_CFG_SHIFT,