diff options
author | Wolfram Sang <wsa-dev@sang-engineering.com> | 2016-07-09 13:34:58 +0900 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2016-07-14 22:06:44 +0900 |
commit | ce0dffafd403e7824ae78a806d08c04ff8112e79 (patch) | |
tree | bb210f5917c399613bf303e7db9da453d48f1acc /drivers | |
parent | cc4618813e4bc409cd22641f6001118ef4479cfc (diff) |
i2c: free idr when sanity checks in i2c_register_adapter() fail
On error, we should give idr back to the pool in any case.
Signed-off-by: Wolfram Sang <wsa-dev@sang-engineering.com>
Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/i2c-core.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 952d2f0c02c5..9f53751e49a7 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -1554,7 +1554,7 @@ static int __process_new_adapter(struct device_driver *d, void *data) static int i2c_register_adapter(struct i2c_adapter *adap) { - int res = 0; + int res = -EINVAL; /* Can't register until after driver model init */ if (WARN_ON(!is_registered)) { @@ -1566,12 +1566,12 @@ static int i2c_register_adapter(struct i2c_adapter *adap) if (unlikely(adap->name[0] == '\0')) { pr_err("i2c-core: Attempt to register an adapter with " "no name!\n"); - return -EINVAL; + goto out_list; } if (unlikely(!adap->algo)) { pr_err("i2c-core: Attempt to register adapter '%s' with " "no algo!\n", adap->name); - return -EINVAL; + goto out_list; } if (!adap->lock_bus) { |