]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init
authorJudith Mendez <jm@ti.com>
Wed, 13 May 2026 23:11:53 +0000 (18:11 -0500)
committerLinus Walleij <linusw@kernel.org>
Mon, 25 May 2026 07:50:48 +0000 (09:50 +0200)
Regmap initialization triggers regcache_maple_populate() which attempts
SPI read to populate cache. SPI read requires mcp->dev and mcp->addr to
be set, without them, NULL pointer dereference occurs during probe.

Move initialization before mcp23s08_spi_regmap_init() call.

Cc: stable@vger.kernel.org
Fixes: f9f4fda15e72 ("pinctrl: mcp23s08: init reg_defaults from HW at probe and switch cache type")
Signed-off-by: Judith Mendez <jm@ti.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
drivers/pinctrl/pinctrl-mcp23s08_spi.c

index 54f61c8cb1c0f360b580043e30c40616c5cec65d..5ed368772adb78d1d13a2cf4d5f2dd1595505415 100644 (file)
@@ -10,6 +10,7 @@
 #include "pinctrl-mcp23s08.h"
 
 #define MCP_MAX_DEV_PER_CS     8
+#define MCP23S08_SPI_BASE      0x40
 
 /*
  * A given spi_device can represent up to eight mcp23sxx chips
@@ -173,6 +174,8 @@ static int mcp23s08_probe(struct spi_device *spi)
        for_each_set_bit(addr, &spi_present_mask, MCP_MAX_DEV_PER_CS) {
                data->mcp[addr] = &data->chip[--chips];
                data->mcp[addr]->irq = spi->irq;
+               data->mcp[addr]->dev = dev;
+               data->mcp[addr]->addr = MCP23S08_SPI_BASE | (addr << 1);
 
                ret = mcp23s08_spi_regmap_init(data->mcp[addr], dev, addr, info);
                if (ret)
@@ -184,7 +187,7 @@ static int mcp23s08_probe(struct spi_device *spi)
                if (!data->mcp[addr]->pinctrl_desc.name)
                        return -ENOMEM;
 
-               ret = mcp23s08_probe_one(data->mcp[addr], dev, 0x40 | (addr << 1),
+               ret = mcp23s08_probe_one(data->mcp[addr], dev, MCP23S08_SPI_BASE | (addr << 1),
                                         info->type, -1);
                if (ret < 0)
                        return ret;