hwmon: (sht15) Fix memory leak if regulator_enable() fails
Ben Hutchings [Sat, 16 Mar 2013 13:32:16 +0000 (06:32 -0700)]
Commit 3e78080f8148 ('hwmon: (sht15) Check return value of
regulator_enable()') depends on the use of devm_kmalloc() for automatic
resource cleanup in the failure cases, which was introduced in 3.7.  In
older stable branches, explicit cleanup is needed.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

drivers/hwmon/sht15.c

index eb01802..c689630 100644 (file)
@@ -930,7 +930,7 @@ static int __devinit sht15_probe(struct platform_device *pdev)
                if (ret != 0) {
                        dev_err(&pdev->dev,
                                "failed to enable regulator: %d\n", ret);
-                       return ret;
+                       goto err_free_data;
                }
 
                /*