提交 ccc5c306 编写于 作者: R Rudolf Marek 提交者: Greg Kroah-Hartman

w83l785ts: Fix unchecked return status

w83l785ts: Fix unchecked return status

Fix the w83l785ts driver. Add error checking to device_create_file
and also care to destroy the files upon exit.
Signed-off-by: NRudolf Marek <r.marek@assembler.cz>
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 311ce2ef
...@@ -236,21 +236,30 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -236,21 +236,30 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
* Nothing yet, assume it is already started. * Nothing yet, assume it is already started.
*/ */
err = device_create_file(&new_client->dev,
&sensor_dev_attr_temp1_input.dev_attr);
if (err)
goto exit_remove;
err = device_create_file(&new_client->dev,
&sensor_dev_attr_temp1_max.dev_attr);
if (err)
goto exit_remove;
/* Register sysfs hooks */ /* Register sysfs hooks */
data->class_dev = hwmon_device_register(&new_client->dev); data->class_dev = hwmon_device_register(&new_client->dev);
if (IS_ERR(data->class_dev)) { if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev); err = PTR_ERR(data->class_dev);
goto exit_detach; goto exit_remove;
} }
device_create_file(&new_client->dev,
&sensor_dev_attr_temp1_input.dev_attr);
device_create_file(&new_client->dev,
&sensor_dev_attr_temp1_max.dev_attr);
return 0; return 0;
exit_detach: exit_remove:
device_remove_file(&new_client->dev,
&sensor_dev_attr_temp1_input.dev_attr);
device_remove_file(&new_client->dev,
&sensor_dev_attr_temp1_max.dev_attr);
i2c_detach_client(new_client); i2c_detach_client(new_client);
exit_free: exit_free:
kfree(data); kfree(data);
...@@ -264,7 +273,10 @@ static int w83l785ts_detach_client(struct i2c_client *client) ...@@ -264,7 +273,10 @@ static int w83l785ts_detach_client(struct i2c_client *client)
int err; int err;
hwmon_device_unregister(data->class_dev); hwmon_device_unregister(data->class_dev);
device_remove_file(&client->dev,
&sensor_dev_attr_temp1_input.dev_attr);
device_remove_file(&client->dev,
&sensor_dev_attr_temp1_max.dev_attr);
if ((err = i2c_detach_client(client))) if ((err = i2c_detach_client(client)))
return err; return err;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册