From a790df272a20dcc88ffebe20eca34c54f528fcaa Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Tue, 3 Sep 2024 13:59:06 -0700 Subject: [PATCH] Input: synaptics-rmi4 - fix crash when DPM query is not supported Stop clobbering "item" variable when checking if the device supports querying DPM values because its original value is still needed in case when we need to fall back to the old way of figuring sensor size. Reported-by: Richard Acayan Tested-by: Richard Acayan Fixes: 14d650fcb7fb ("Input: synaptics-rmi4 - add support for querying DPM value (F12)") Link: https://lore.kernel.org/r/ZtdQW7nqAOEJDNBN@radian Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f12.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index fc2cc8e2b0ba..8246fe77114b 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c @@ -129,9 +129,8 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12) * Use the Query DPM feature when the resolution query register * exists. */ - item = rmi_get_register_desc_item(&f12->query_reg_desc, - RMI_F12_QUERY_RESOLUTION); - if (item) { + if (rmi_get_register_desc_item(&f12->query_reg_desc, + RMI_F12_QUERY_RESOLUTION)) { offset = rmi_register_desc_calc_reg_offset(&f12->query_reg_desc, RMI_F12_QUERY_RESOLUTION); query_dpm_addr = fn->fd.query_base_addr + offset;