This is a note to let you know that I've just added the patch titled
iio: cm36651: Fix i2c client leak and possible NULL pointer dereference
to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
iio-cm36651-fix-i2c-client-leak-and-possible-null-pointer-dereference.patch
and it can be found in the queue-3.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <[email protected]> know about it.
>From d0a588a57c2b0748df8307a0865a1bbbf1624c53 Mon Sep 17 00:00:00 2001
From: Krzysztof Kozlowski <[email protected]>
Date: Tue, 18 Mar 2014 08:13:00 +0000
Subject: iio: cm36651: Fix i2c client leak and possible NULL pointer dereference
From: Krzysztof Kozlowski <[email protected]>
commit d0a588a57c2b0748df8307a0865a1bbbf1624c53 upstream.
During probe the driver allocates dummy I2C devices (i2c_new_dummy())
but they aren't unregistered during driver remove or probe failure.
Additionally driver does not check the return value of i2c_new_dummy().
In case of error (i2c_new_device(): memory allocation failure or I2C
address cannot be used) this function returns NULL which is later
dereferenced by i2c_smbus_{read,write}_data() functions.
Fix issues by properly checking for i2c_new_dummy() return value and
unregistering I2C devices on driver remove or probe failure.
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Acked-by: Beomho Seo <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
drivers/iio/light/cm36651.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
--- a/drivers/iio/light/cm36651.c
+++ b/drivers/iio/light/cm36651.c
@@ -652,7 +652,19 @@ static int cm36651_probe(struct i2c_clie
cm36651->client = client;
cm36651->ps_client = i2c_new_dummy(client->adapter,
CM36651_I2C_ADDR_PS);
+ if (!cm36651->ps_client) {
+ dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
+ ret = -ENODEV;
+ goto error_disable_reg;
+ }
+
cm36651->ara_client = i2c_new_dummy(client->adapter, CM36651_ARA);
+ if (!cm36651->ara_client) {
+ dev_err(&client->dev, "%s: new i2c device failed\n", __func__);
+ ret = -ENODEV;
+ goto error_i2c_unregister_ps;
+ }
+
mutex_init(&cm36651->lock);
indio_dev->dev.parent = &client->dev;
indio_dev->channels = cm36651_channels;
@@ -664,7 +676,7 @@ static int cm36651_probe(struct i2c_clie
ret = cm36651_setup_reg(cm36651);
if (ret) {
dev_err(&client->dev, "%s: register setup failed\n", __func__);
- goto error_disable_reg;
+ goto error_i2c_unregister_ara;
}
ret = request_threaded_irq(client->irq, NULL, cm36651_irq_handler,
@@ -672,7 +684,7 @@ static int cm36651_probe(struct i2c_clie
"cm36651", indio_dev);
if (ret) {
dev_err(&client->dev, "%s: request irq failed\n", __func__);
- goto error_disable_reg;
+ goto error_i2c_unregister_ara;
}
ret = iio_device_register(indio_dev);
@@ -685,6 +697,10 @@ static int cm36651_probe(struct i2c_clie
error_free_irq:
free_irq(client->irq, indio_dev);
+error_i2c_unregister_ara:
+ i2c_unregister_device(cm36651->ara_client);
+error_i2c_unregister_ps:
+ i2c_unregister_device(cm36651->ps_client);
error_disable_reg:
regulator_disable(cm36651->vled_reg);
return ret;
@@ -698,6 +714,8 @@ static int cm36651_remove(struct i2c_cli
iio_device_unregister(indio_dev);
regulator_disable(cm36651->vled_reg);
free_irq(client->irq, indio_dev);
+ i2c_unregister_device(cm36651->ps_client);
+ i2c_unregister_device(cm36651->ara_client);
return 0;
}
Patches currently in stable-queue which might be from [email protected]
are
queue-3.14/mfd-max8998-fix-possible-null-pointer-dereference-on-i2c_new_dummy-error.patch
queue-3.14/mfd-tps65910-fix-possible-invalid-pointer-dereference-on-regmap_add_irq_chip-fail.patch
queue-3.14/mfd-88pm860x-fix-i2c-device-resource-leak-on-regmap-init-fail.patch
queue-3.14/mfd-88pm860x-fix-possible-null-pointer-dereference-on-i2c_new_dummy-error.patch
queue-3.14/mfd-max77686-fix-possible-null-pointer-dereference-on-i2c_new_dummy-error.patch
queue-3.14/mfd-88pm800-fix-i2c-device-resource-leak-if-probe-fails.patch
queue-3.14/mfd-max8925-fix-possible-null-pointer-dereference-on-i2c_new_dummy-error.patch
queue-3.14/mfd-max77693-fix-possible-null-pointer-dereference-on-i2c_new_dummy-error.patch
queue-3.14/iio-cm36651-fix-i2c-client-leak-and-possible-null-pointer-dereference.patch
queue-3.14/mfd-sec-core-fix-possible-null-pointer-dereference-when-i2c_new_dummy-error.patch
queue-3.14/mfd-max8997-fix-possible-null-pointer-dereference-on-i2c_new_dummy-error.patch
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html