public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] irqchip/qcom-pdc: don't read version register if it is not available
@ 2023-08-25 21:35 Dmitry Baryshkov
  2023-08-25 21:35 ` [PATCH 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource Dmitry Baryshkov
  2023-08-28  9:36 ` [PATCH 1/2] irqchip/qcom-pdc: don't read version register if it is not available Maulik Shah (mkshah)
  0 siblings, 2 replies; 12+ messages in thread
From: Dmitry Baryshkov @ 2023-08-25 21:35 UTC (permalink / raw)
  To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Thomas Gleixner,
	Marc Zyngier
  Cc: linux-arm-msm, linux-kernel, Neil Armstrong

On Qualcomm SM8150 the PDC resource has size 0x400. When PDC driver
tries to read the version register (0x1000), it reads past the end of
this resource, causing kernel crash.

Check the size of PDC resource before reading the PDC_VERSION register.

Fixes: bc82cc42644b ("irqchip/qcom-pdc: Add support for v3.2 HW")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/irqchip/qcom-pdc.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/qcom-pdc.c b/drivers/irqchip/qcom-pdc.c
index 9bb6951257c2..431b213b5abb 100644
--- a/drivers/irqchip/qcom-pdc.c
+++ b/drivers/irqchip/qcom-pdc.c
@@ -324,6 +324,7 @@ static int pdc_setup_pin_mapping(struct device_node *np)
 static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
 {
 	struct irq_domain *parent_domain, *pdc_domain;
+	struct resource res;
 	int ret;
 
 	pdc_base = of_iomap(node, 0);
@@ -332,7 +333,14 @@ static int qcom_pdc_init(struct device_node *node, struct device_node *parent)
 		return -ENXIO;
 	}
 
-	pdc_version = pdc_reg_read(PDC_VERSION, 0);
+	if (of_address_to_resource(node, 0, &res))
+		return -EINVAL;
+
+	/* compat with old sm8150 DT which had very small region for PDC */
+	if (resource_size(&res) > PDC_VERSION)
+		pdc_version = pdc_reg_read(PDC_VERSION, 0);
+	else
+		pdc_version = 0;
 
 	parent_domain = irq_find_host(parent);
 	if (!parent_domain) {
-- 
2.39.2


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

end of thread, other threads:[~2023-08-29  4:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-25 21:35 [PATCH 1/2] irqchip/qcom-pdc: don't read version register if it is not available Dmitry Baryshkov
2023-08-25 21:35 ` [PATCH 2/2] arm64: dts: qcom: sm8150: extend the size of the PDC resource Dmitry Baryshkov
2023-08-26  9:49   ` Konrad Dybcio
2023-08-28  9:36 ` [PATCH 1/2] irqchip/qcom-pdc: don't read version register if it is not available Maulik Shah (mkshah)
2023-08-28  9:45   ` Konrad Dybcio
2023-08-28  9:46   ` Dmitry Baryshkov
2023-08-28 10:04     ` Marc Zyngier
2023-08-28 10:18       ` Dmitry Baryshkov
2023-08-28 10:26         ` Marc Zyngier
2023-08-28 12:02         ` Neil Armstrong
2023-08-29  4:25         ` Maulik Shah (mkshah)
2023-08-28 10:20       ` Konrad Dybcio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox