Skip to contentSkip to conversation

IIO: si7020: Allocate correct amount of memory in devm_iio_device_alloc

PATCH Applied Andrey Smirnov 2 participants 2 messages Feb 13, 2015 – Feb 14, 2015 IIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IIO: si7020: Allocate correct amount of memory in devm_iio_device_alloc

Since only a pointer to struct i2c_client is stored in a private area of IIO device created by the driver there's no need to allocate sizeof(struct i2c_client) worth of storage.

---
 drivers/iio/humidity/si7020.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/humidity/si7020.c +1 -1
index 69e49f5..fa3b809 100644
@@ -126,7 +126,7 @@ static int si7020_probe(struct i2c_client *client,
 	/* Wait the maximum power-up time after software reset. */
 	msleep(15);
 
-	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client));
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
 		return -ENOMEM;
 

--
2.1.0

maintainer Applied
#1 lore raw
Quoted 5 lines · Andrey Smirnov

Since only a pointer to struct i2c_client is stored in a private area of IIO device created by the driver there's no need to allocate sizeof(struct i2c_client) worth of storage.

Applied to the fixes-togreg branch of iio.git. Marked for stable to make sure this confusion doesn't arise again!

Jonathan

Quoted 20 lines
---
 drivers/iio/humidity/si7020.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/humidity/si7020.c +1 -2
index 69e49f5..fa3b809 100644
@@ -126,7 +126,7 @@ static int si7020_probe(struct i2c_client *client,
 	/* Wait the maximum power-up time after software reset. */
 	msleep(15);
 
-	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*client));
+	indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
 	if (!indio_dev)
 		return -ENOMEM;
 
--

2.1.0