pinctrl-mcp23s08: Dup full chunk of memory for regmap configuration
Subsystems (2)
PATCH 1/2 pinctrl-mcp23s08: Dup full chunk of memory for regmap configuration
It appears that simplification of mcp23s08_spi_regmap_init() made a regression due to wrong size calculation for dev,_kmemdup() call. It mises the fact that config variable is already a pointer, thus the sizeof() calculation is wrong and only 4/8 bytes were copied.
Fix the parameters to devm_kmemdup() to copy full chunk of memory.
Fixes 0874758ecb2b ("pinctrl: mcp23s08: Refactor mcp23s08_spi_regmap_init()")
Reported-by Martin Hundebøll <[email protected]>
Signed-off-by Andy Shevchenko <[email protected]>
--- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-mcp23s08_spi.c +1 -1
@@ -119,7 +119,7 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev,return -EINVAL ; } - copy =devm_kmemdup (dev, &config,sizeof (config),GFP_KERNEL ); + copy =devm_kmemdup (dev, config,sizeof (*config),GFP_KERNEL );if (!copy)return -ENOMEM ;
Signature · 1 line
2.28.0
PATCH 2/2 pinctrl: mcp23s08: Print error message when regmap init fails
It is useful for debugging to have the error message printed when regmap initialisation fails. Add it to the driver.
Cc Martin Hundebøll <[email protected]>
Signed-off-by Andy Shevchenko <[email protected]>
--- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/pinctrl-mcp23s08_spi.c +2 -0
@@ -126,6 +126,8 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev, copy->name = name; mcp->regmap =devm_regmap_init (dev, &mcp23sxx_spi_regmap, mcp, copy); +if (IS_ERR (mcp->regmap)) +dev_err (dev,"regmap init failed for %s\n" , mcp->chip.label);return PTR_ERR_OR_ZERO (mcp->regmap); }
Signature · 1 line
2.28.0