* [PATCH] memory: tegra: Guard against NULL mc_regs in IRQ handler
@ 2026-07-03 4:56 Ashish Mhetre
2026-07-08 11:16 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Ashish Mhetre @ 2026-07-03 4:56 UTC (permalink / raw)
To: krzk, thierry.reding, jonathanh; +Cc: linux-kernel, linux-tegra, Ashish Mhetre
The per-error decode in tegra30_mc_handle_irq() dereferences
mc->soc->regs unconditionally. This 'regs' structure is optional and is
only used for decoding and logging MC error interrupts. The rest of the
MC functionality does not depend on it.
When adding support for the Tegra238 SoC, the 'regs' structure was
initially omitted because it is only used for error logging. We found
that this resulted in a NULL pointer dereference in IRQ context, causing
a crash when an MC error interrupt fired. Although existing upstream
devices will not hit this condition because 'regs' is present, guard
against it to improve the robustness of the driver.
Skip the decode and just clear the interrupt when mc_regs is NULL. This
bypasses the error interrupt logging while keeping the remaining MC
functionality intact.
Signed-off-by: Ashish Mhetre <amhetre@nvidia.com>
---
drivers/memory/tegra/mc.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/memory/tegra/mc.c b/drivers/memory/tegra/mc.c
index ec80ea9cc173..6ac7d5f5e597 100644
--- a/drivers/memory/tegra/mc.c
+++ b/drivers/memory/tegra/mc.c
@@ -598,6 +598,13 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data)
if (!status)
return IRQ_NONE;
+ if (!mc->soc->regs) {
+ dev_err_ratelimited(mc->dev,
+ "MC error interrupt 0x%08lx with no error register map, Clearing.\n",
+ status);
+ goto clear;
+ }
+
for_each_set_bit(bit, &status, 32) {
const char *error = tegra_mc_status_names[bit] ?: "unknown";
const char *client = "unknown", *desc;
@@ -736,6 +743,7 @@ irqreturn_t tegra30_mc_handle_irq(int irq, void *data)
desc, perm);
}
+clear:
/* clear interrupts */
if (mc->soc->num_channels) {
mc_ch_writel(mc, channel, status, MC_INTSTATUS);
--
2.50.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] memory: tegra: Guard against NULL mc_regs in IRQ handler
2026-07-03 4:56 [PATCH] memory: tegra: Guard against NULL mc_regs in IRQ handler Ashish Mhetre
@ 2026-07-08 11:16 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2026-07-08 11:16 UTC (permalink / raw)
To: thierry.reding, jonathanh, Ashish Mhetre; +Cc: linux-kernel, linux-tegra
On Fri, 03 Jul 2026 04:56:53 +0000, Ashish Mhetre wrote:
> The per-error decode in tegra30_mc_handle_irq() dereferences
> mc->soc->regs unconditionally. This 'regs' structure is optional and is
> only used for decoding and logging MC error interrupts. The rest of the
> MC functionality does not depend on it.
>
> When adding support for the Tegra238 SoC, the 'regs' structure was
> initially omitted because it is only used for error logging. We found
> that this resulted in a NULL pointer dereference in IRQ context, causing
> a crash when an MC error interrupt fired. Although existing upstream
> devices will not hit this condition because 'regs' is present, guard
> against it to improve the robustness of the driver.
>
> [...]
Applied, thanks!
[1/1] memory: tegra: Guard against NULL mc_regs in IRQ handler
https://git.kernel.org/krzk/linux-mem-ctrl/c/8111c7f3723f414b7f655a3880775cbbd0e9de8e
Best regards,
--
Krzysztof Kozlowski <krzk@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-08 11:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-03 4:56 [PATCH] memory: tegra: Guard against NULL mc_regs in IRQ handler Ashish Mhetre
2026-07-08 11:16 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome