linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: mtk-pmic-keys: Fix probe when no DT node present
@ 2018-06-22 11:42 Matthias Brugger
  2018-06-22 18:31 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Brugger @ 2018-06-22 11:42 UTC (permalink / raw)
  To: dmitry.torokhov, chen.zhong, lee.jones
  Cc: matthias.bgg, linux-input, linux-arm-kernel, linux-mediatek,
	linux-kernel, Matthias Brugger

The drivers gets probed from a mfd devices. So the driver runs
probe although no DT node exists. This leads to a NULL pointer
dereference in the probe function. Check if a node exists and
error out in case none is present.

Fixes: 3e9f0b3e2b27 ("input: Add MediaTek PMIC keys support")
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/input/keyboard/mtk-pmic-keys.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
index 02c67a1749fc..388043e1939c 100644
--- a/drivers/input/keyboard/mtk-pmic-keys.c
+++ b/drivers/input/keyboard/mtk-pmic-keys.c
@@ -257,6 +257,9 @@ static int mtk_pmic_keys_probe(struct platform_device *pdev)
 	const struct of_device_id *of_id =
 		of_match_device(of_mtk_pmic_keys_match_tbl, &pdev->dev);
 
+	if (of_id == NULL)
+		return -ENODEV;
+
 	keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL);
 	if (!keys)
 		return -ENOMEM;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-03  9:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-22 11:42 [PATCH] input: mtk-pmic-keys: Fix probe when no DT node present Matthias Brugger
2018-06-22 18:31 ` Dmitry Torokhov
2018-07-03  9:17   ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).