summaryrefslogtreecommitdiff
path: root/drivers/input
diff options
context:
space:
mode:
authorGary Bisson <bisson.gary@gmail.com>2025-04-29 09:16:29 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-05-18 08:24:50 +0200
commit619c05fb176c272ac6cecf723446b39723ee6d97 (patch)
tree6b22a472c373fb26c8fc2b11f2d968734cf48665 /drivers/input
parentf36230dacde99a0fa5f1b4a7032fa28f4703adbc (diff)
downloadlinux-619c05fb176c272ac6cecf723446b39723ee6d97.tar.gz
linux-619c05fb176c272ac6cecf723446b39723ee6d97.tar.bz2
linux-619c05fb176c272ac6cecf723446b39723ee6d97.zip
Input: mtk-pmic-keys - fix possible null pointer dereference
commit 11cdb506d0fbf5ac05bf55f5afcb3a215c316490 upstream. In mtk_pmic_keys_probe, the regs parameter is only set if the button is parsed in the device tree. However, on hardware where the button is left floating, that node will most likely be removed not to enable that input. In that case the code will try to dereference a null pointer. Let's use the regs struct instead as it is defined for all supported platforms. Note that it is ok setting the key reg even if that latter is disabled as the interrupt won't be enabled anyway. Fixes: b581acb49aec ("Input: mtk-pmic-keys - transfer per-key bit in mtk_pmic_keys_regs") Signed-off-by: Gary Bisson <bisson.gary@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/mtk-pmic-keys.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 4364c3401ff1..486ca8ff86f8 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -147,8 +147,8 @@ static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
u32 value, mask;
int error;
- kregs_home = keys->keys[MTK_PMIC_HOMEKEY_INDEX].regs;
- kregs_pwr = keys->keys[MTK_PMIC_PWRKEY_INDEX].regs;
+ kregs_home = &regs->keys_regs[MTK_PMIC_HOMEKEY_INDEX];
+ kregs_pwr = &regs->keys_regs[MTK_PMIC_PWRKEY_INDEX];
error = of_property_read_u32(keys->dev->of_node, "power-off-time-sec",
&long_press_debounce);