hwmon: (ads1015) Fix file leak in probe function

An error while creating sysfs attribute files in the driver's probe function
results in an error abort, but already created files are not removed. This patch
fixes the problem.

Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Cc: stable@vger.kernel.org # 3.0+
Cc: Dirk Eibach <eibach@gdsys.de>
Acked-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
Guenter Roeck 2012-02-22 08:13:52 -08:00
parent 2f2da1ac0b
commit 363434b5dc

View File

@ -271,7 +271,7 @@ static int ads1015_probe(struct i2c_client *client,
continue; continue;
err = device_create_file(&client->dev, &ads1015_in[k].dev_attr); err = device_create_file(&client->dev, &ads1015_in[k].dev_attr);
if (err) if (err)
goto exit_free; goto exit_remove;
} }
data->hwmon_dev = hwmon_device_register(&client->dev); data->hwmon_dev = hwmon_device_register(&client->dev);
@ -285,7 +285,6 @@ static int ads1015_probe(struct i2c_client *client,
exit_remove: exit_remove:
for (k = 0; k < ADS1015_CHANNELS; ++k) for (k = 0; k < ADS1015_CHANNELS; ++k)
device_remove_file(&client->dev, &ads1015_in[k].dev_attr); device_remove_file(&client->dev, &ads1015_in[k].dev_attr);
exit_free:
kfree(data); kfree(data);
exit: exit:
return err; return err;