Commit 07125ab2 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

i2c: Refactor a kfree in i2c-dev

Refactor kfree(i2c_dev) into return_i2c_dev(). This saves some
code and makes more sense, as the memory is allocated in
get_free_i2c_dev().
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
parent 3bacb36d
...@@ -90,6 +90,7 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev) ...@@ -90,6 +90,7 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
spin_lock(&i2c_dev_list_lock); spin_lock(&i2c_dev_list_lock);
list_del(&i2c_dev->list); list_del(&i2c_dev->list);
spin_unlock(&i2c_dev_list_lock); spin_unlock(&i2c_dev_list_lock);
kfree(i2c_dev);
} }
static ssize_t show_adapter_name(struct device *dev, static ssize_t show_adapter_name(struct device *dev,
...@@ -431,7 +432,6 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) ...@@ -431,7 +432,6 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
error: error:
return_i2c_dev(i2c_dev); return_i2c_dev(i2c_dev);
kfree(i2c_dev);
return res; return res;
} }
...@@ -446,7 +446,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap) ...@@ -446,7 +446,6 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
device_remove_file(i2c_dev->dev, &dev_attr_name); device_remove_file(i2c_dev->dev, &dev_attr_name);
return_i2c_dev(i2c_dev); return_i2c_dev(i2c_dev);
device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr)); device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
kfree(i2c_dev);
pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment