* [PATCH] Input: mtk-pmic-keys - fix possible null pointer dereference
@ 2025-04-29 12:28 Gary Bisson
2025-04-29 16:29 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Gary Bisson @ 2025-04-29 12:28 UTC (permalink / raw)
To: angelogioacchino.delregno, matthias.bgg
Cc: dmitry.torokhov, linux-input, linux-mediatek, Gary Bisson
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: b581acb49aec5 ("Input: mtk-pmic-keys - transfer per-key bit in
mtk_pmic_keys_regs")
Signed-off-by: Gary Bisson <bisson.gary@gmail.com>
---
drivers/input/keyboard/mtk-pmic-keys.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 5ad6be9141603..061d48350df66 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 = ®s->keys_regs[MTK_PMIC_HOMEKEY_INDEX];
+ kregs_pwr = ®s->keys_regs[MTK_PMIC_PWRKEY_INDEX];
error = of_property_read_u32(keys->dev->of_node, "power-off-time-sec",
&long_press_debounce);
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] Input: mtk-pmic-keys - fix possible null pointer dereference
2025-04-29 12:28 [PATCH] Input: mtk-pmic-keys - fix possible null pointer dereference Gary Bisson
@ 2025-04-29 16:29 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2025-04-29 16:29 UTC (permalink / raw)
To: Gary Bisson
Cc: angelogioacchino.delregno, matthias.bgg, linux-input,
linux-mediatek
On Tue, Apr 29, 2025 at 02:28:15PM +0200, Gary Bisson wrote:
> 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: b581acb49aec5 ("Input: mtk-pmic-keys - transfer per-key bit in
> mtk_pmic_keys_regs")
>
> Signed-off-by: Gary Bisson <bisson.gary@gmail.com>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-29 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-29 12:28 [PATCH] Input: mtk-pmic-keys - fix possible null pointer dereference Gary Bisson
2025-04-29 16:29 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox