diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c index 3beed6ea8c6568fbd4d560e5dd2da8f6102ba167..0de8c7008122bfe3d044716a380831ae193e399d 100644 --- a/drivers/gpio/gpio-adp5588.c +++ b/drivers/gpio/gpio-adp5588.c @@ -378,7 +378,7 @@ static int adp5588_gpio_probe(struct i2c_client *client, return -EIO; } - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); if (dev == NULL) return -ENOMEM; @@ -446,7 +446,6 @@ static int adp5588_gpio_probe(struct i2c_client *client, err_irq: adp5588_irq_teardown(dev); err: - kfree(dev); return ret; } diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index eea5d7e578c994bd28b04271837d06fe3fee3d69..a17b81fea1612a9d4222ae23d7173930799257d9 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c @@ -949,10 +949,12 @@ static int mcp23s08_probe(struct spi_device *spi) if (!chips) return -ENODEV; - data = kzalloc(sizeof(*data) + chips * sizeof(struct mcp23s08), - GFP_KERNEL); + data = devm_kzalloc(&spi->dev, + sizeof(*data) + chips * sizeof(struct mcp23s08), + GFP_KERNEL); if (!data) return -ENOMEM; + spi_set_drvdata(spi, data); spi->irq = irq_of_parse_and_map(spi->dev.of_node, 0); @@ -989,7 +991,6 @@ static int mcp23s08_probe(struct spi_device *spi) continue; gpiochip_remove(&data->mcp[addr]->chip); } - kfree(data); return status; }