Skip to contentSkip to conversation

input: keyboard: snvs: initialize necessary driver data before enabling IRQ

PATCH Applied Anson Huang 2 participants 2 messages Mar 27, 2019 – Apr 3, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 input: keyboard: snvs: initialize necessary driver data before enabling IRQ

SNVS IRQ is requested before necessary driver data initialized, if there is a pending IRQ during driver probe phase, kernel NULL pointer panic will occur in IRQ handler. To avoid such scenario, just initialize necessary driver data before enabling IRQ. This patch is inspired by NXP's internal kernel tree.

Fixes d3dc6e232215 ("input: keyboard: imx: add snvs power key driver")

---
Changes since V1:
- move the platform data initialization to before IRQ enable instead of moving the IRQ enable to the end of probe function.

---
 drivers/input/keyboard/snvs_pwrkey.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/keyboard/snvs_pwrkey.c +3 -3
index effb632..4c67cf3 100644
@@ -148,6 +148,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 		return error;
 	}
 
+	pdata->input = input;
+	platform_set_drvdata(pdev, pdata);
+
 	error = devm_request_irq(&pdev->dev, pdata->irq,
 			       imx_snvs_pwrkey_interrupt,
 			       0, pdev->name, pdev);
@@ -163,9 +166,6 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	pdata->input = input;
-	platform_set_drvdata(pdev, pdata);
-
 	device_init_wakeup(&pdev->dev, pdata->wakeup);
 
 	return 0;
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw
Quoted 8 lines · Anson Huang

SNVS IRQ is requested before necessary driver data initialized, if there is a pending IRQ during driver probe phase, kernel NULL pointer panic will occur in IRQ handler. To avoid such scenario, just initialize necessary driver data before enabling IRQ. This patch is inspired by NXP's internal kernel tree.

Fixes d3dc6e232215 ("input: keyboard: imx: add snvs power key driver")

Applied, thank you.

Quoted 35 lines

---
Changes since V1:
- move the platform data initialization to before IRQ enable instead of moving the IRQ enable to the end of probe function.

---
 drivers/input/keyboard/snvs_pwrkey.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/keyboard/snvs_pwrkey.c +3 -3
index effb632..4c67cf3 100644
@@ -148,6 +148,9 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 		return error;
 	}
 
+	pdata->input = input;
+	platform_set_drvdata(pdev, pdata);
+
 	error = devm_request_irq(&pdev->dev, pdata->irq,
 			       imx_snvs_pwrkey_interrupt,
 			       0, pdev->name, pdev);
@@ -163,9 +166,6 @@ static int imx_snvs_pwrkey_probe(struct platform_device *pdev)
 		return error;
 	}
 
-	pdata->input = input;
-	platform_set_drvdata(pdev, pdata);
-
 	device_init_wakeup(&pdev->dev, pdata->wakeup);
 
 	return 0;
Signature · 1 line
2.7.4
Signature · 1 line
Dmitry