gpio: stmpe: Check return value of stmpe_reg_read in stmpe_gpio_irq_sync_unlock
The stmpe_reg_read function can fail, but its return value is not checked
in stmpe_gpio_irq_sync_unlock. This can lead to silent failures and
incorrect behavior if the hardware access fails.
This patch adds checks for the return value of stmpe_reg_read. If the
function fails, an error message is logged and the function returns
early to avoid further issues.
Fixes: b888fb6f2a
("gpio: stmpe: i2c transfer are forbiden in atomic context")
Cc: stable@vger.kernel.org # 4.16+
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Link: https://lore.kernel.org/r/20250212021849.275-1-vulab@iscas.ac.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
parent
8743d66979
commit
b9644fbfbc
1 changed files with 12 additions and 3 deletions
|
@ -191,7 +191,7 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d)
|
|||
[REG_IE][CSB] = STMPE_IDX_IEGPIOR_CSB,
|
||||
[REG_IE][MSB] = STMPE_IDX_IEGPIOR_MSB,
|
||||
};
|
||||
int i, j;
|
||||
int ret, i, j;
|
||||
|
||||
/*
|
||||
* STMPE1600: to be able to get IRQ from pins,
|
||||
|
@ -199,8 +199,16 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d)
|
|||
* GPSR or GPCR registers
|
||||
*/
|
||||
if (stmpe->partnum == STMPE1600) {
|
||||
stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_LSB]);
|
||||
stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_CSB]);
|
||||
ret = stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_LSB]);
|
||||
if (ret < 0) {
|
||||
dev_err(stmpe->dev, "Failed to read GPMR_LSB: %d\n", ret);
|
||||
goto err;
|
||||
}
|
||||
ret = stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_CSB]);
|
||||
if (ret < 0) {
|
||||
dev_err(stmpe->dev, "Failed to read GPMR_CSB: %d\n", ret);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < CACHE_NR_REGS; i++) {
|
||||
|
@ -222,6 +230,7 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d)
|
|||
}
|
||||
}
|
||||
|
||||
err:
|
||||
mutex_unlock(&stmpe_gpio->irq_lock);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue