[PATCH 1/7] i2c: free idr when sanity checks in i2c_register_adapter() fail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On error, we should give idr back to the pool in any case.

Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxxxxx>
Cc: Jean Delvare <jdelvare@xxxxxxx>
---
 drivers/i2c/i2c-core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 71ad532be1d891..7e6ff6d4cf659a 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1560,7 +1560,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)) {
@@ -1572,12 +1572,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) {
-- 
2.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux