mfd: sec-core: Fix I2C dummy device resource leak on probe failure
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Tue, 18 Mar 2014 12:57:50 +0000 (13:57 +0100)
committerLee Jones <lee.jones@linaro.org>
Wed, 19 Mar 2014 09:00:08 +0000 (09:00 +0000)
Dummy I2C device allocated in sec_pmic_probe() leaked if
devm_regmap_init_i2c() failed. Unregister it before returning from
probe.

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/sec-core.c

index e9bf73ba6e69e0a8f4492c819786516650134d0d..91405e94cfee2f8badf44a792a0c80293547426d 100644 (file)
@@ -347,7 +347,7 @@ static int sec_pmic_probe(struct i2c_client *i2c,
                ret = PTR_ERR(sec_pmic->regmap_rtc);
                dev_err(&i2c->dev, "Failed to allocate RTC register map: %d\n",
                        ret);
-               return ret;
+               goto err_regmap_rtc;
        }
 
        if (pdata && pdata->cfg_pmic_irq)
@@ -388,14 +388,15 @@ static int sec_pmic_probe(struct i2c_client *i2c,
        }
 
        if (ret)
-               goto err;
+               goto err_mfd;
 
        device_init_wakeup(sec_pmic->dev, sec_pmic->wakeup);
 
        return ret;
 
-err:
+err_mfd:
        sec_irq_exit(sec_pmic);
+err_regmap_rtc:
        i2c_unregister_device(sec_pmic->rtc);
        return ret;
 }