mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init
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: f9f4fda15e ("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>
This commit is contained in:
parent
e7ae89a0c9
commit
8473c3a197
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user