[PATCH] mfd: intel_quark_i2c_gpio: fix write to const mem

From: Tong Zhang
Date: Sat Mar 20 2021 - 15:39:13 EST


intel_quark_i2c_res and intel_quark_gpio_res are written by
intel_quark_mfd_probe. Making them const can cause page fault.

[ 1.319934] BUG: unable to handle page fault for address: ffffffffc00be140
[ 1.320296] #PF: supervisor write access in kernel mode
[ 1.320571] #PF: error_code(0x0003) - permissions violation
[ 1.322419] RIP: 0010:intel_quark_mfd_probe+0xb7/0x23e [intel_quark_i2c_gpio]
[ 1.327670] Call Trace:
[ 1.327800] local_pci_probe+0x48/0x80

Fixes: c4a164f41554 (mfd: Constify static struct resources)
Signed-off-by: Tong Zhang <ztong0001@xxxxxxxxx>
---
drivers/mfd/intel_quark_i2c_gpio.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/intel_quark_i2c_gpio.c b/drivers/mfd/intel_quark_i2c_gpio.c
index fe8ca945f367..84ca7902e1df 100644
--- a/drivers/mfd/intel_quark_i2c_gpio.c
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -72,7 +72,7 @@ static const struct dmi_system_id dmi_platform_info[] = {
{}
};

-static const struct resource intel_quark_i2c_res[] = {
+static struct resource intel_quark_i2c_res[] = {
[INTEL_QUARK_IORES_MEM] = {
.flags = IORESOURCE_MEM,
},
@@ -85,7 +85,7 @@ static struct mfd_cell_acpi_match intel_quark_acpi_match_i2c = {
.adr = MFD_ACPI_MATCH_I2C,
};

-static const struct resource intel_quark_gpio_res[] = {
+static struct resource intel_quark_gpio_res[] = {
[INTEL_QUARK_IORES_MEM] = {
.flags = IORESOURCE_MEM,
},
--
2.25.1