From c2bdb4abe861b4406214f62bd406d88b16bd862b Mon Sep 17 00:00:00 2001 From: Elaine Zhang Date: Sat, 27 Feb 2016 04:19:23 +0800 Subject: [PATCH] rockchip: power & pmic: fix compile warning fixed the WARNING: invalid free of devm_ allocated data Change-Id: I54514cf53a8a0d1f885fd0a17e7f6db7af1d10f9 Signed-off-by: Elaine Zhang --- drivers/mfd/rk818.c | 1 - drivers/power/bq24296_charger.c | 3 +-- drivers/power/bq27320_battery.c | 17 ++++------------- drivers/power/ricoh619-battery.c | 2 -- drivers/power/rk30_factory_adc_battery.c | 17 +++-------------- drivers/power/rt5025-battery.c | 1 - drivers/regulator/act8846.c | 7 ++++--- drivers/regulator/act8931.c | 9 ++++----- drivers/rtc/rtc-ricoh619.c | 9 +-------- 9 files changed, 17 insertions(+), 49 deletions(-) diff --git a/drivers/mfd/rk818.c b/drivers/mfd/rk818.c index ff24a2f87f25..616d56650592 100755 --- a/drivers/mfd/rk818.c +++ b/drivers/mfd/rk818.c @@ -1381,7 +1381,6 @@ static int rk818_i2c_remove(struct i2c_client *i2c) if (rk818->rdev[i]) regulator_unregister(rk818->rdev[i]); i2c_set_clientdata(i2c, NULL); - kfree(rk818); return 0; } diff --git a/drivers/power/bq24296_charger.c b/drivers/power/bq24296_charger.c index 9bdc35e8877c..09a8d7f88735 100755 --- a/drivers/power/bq24296_charger.c +++ b/drivers/power/bq24296_charger.c @@ -608,8 +608,7 @@ static void bq24296_battery_shutdown(struct i2c_client *client) static int bq24296_battery_remove(struct i2c_client *client) { - struct bq24296_device_info *di = i2c_get_clientdata(client); - kfree(di); + return 0; } diff --git a/drivers/power/bq27320_battery.c b/drivers/power/bq27320_battery.c index 349547f41af6..7d5e15ac15b3 100755 --- a/drivers/power/bq27320_battery.c +++ b/drivers/power/bq27320_battery.c @@ -1300,22 +1300,16 @@ static int bq27320_battery_probe(struct i2c_client *client, bq27320_powersupply_init(di); retval = power_supply_register(&client->dev, &di->bat); - if (retval) { + if (retval) dev_err(&client->dev, "failed to register battery\n"); - goto batt_failed_4; - } - + retval = power_supply_register(&client->dev, &di->usb); - if (retval) { + if (retval) dev_err(&client->dev, "failed to register ac\n"); - goto batt_failed_4; - } retval = power_supply_register(&client->dev, &di->ac); - if (retval) { + if (retval) dev_err(&client->dev, "failed to register ac\n"); - goto batt_failed_4; - } g_bq27320_i2c_client = client; @@ -1333,8 +1327,6 @@ static int bq27320_battery_probe(struct i2c_client *client, return 0; -batt_failed_4: - kfree(di); batt_failed_3: driver_remove_file(&(bq27320_battery_driver.driver), &driver_attr_state); batt_failed_2: @@ -1354,7 +1346,6 @@ static int bq27320_battery_remove(struct i2c_client *client) kfree(di->bat.name); kfree(di->usb.name); kfree(di->ac.name); - kfree(di); return 0; } diff --git a/drivers/power/ricoh619-battery.c b/drivers/power/ricoh619-battery.c index d4da2416ea91..24e840aef59c 100755 --- a/drivers/power/ricoh619-battery.c +++ b/drivers/power/ricoh619-battery.c @@ -4504,7 +4504,6 @@ static int ricoh619_battery_probe(struct platform_device *pdev) return 0; out: - kfree(info); return ret; } @@ -4608,7 +4607,6 @@ static int ricoh619_battery_remove(struct platform_device *pdev) #endif power_supply_unregister(&info->battery); - kfree(info); platform_set_drvdata(pdev, NULL); return 0; } diff --git a/drivers/power/rk30_factory_adc_battery.c b/drivers/power/rk30_factory_adc_battery.c index 6ae42e4fe29b..9d4b7dfc74ae 100755 --- a/drivers/power/rk30_factory_adc_battery.c +++ b/drivers/power/rk30_factory_adc_battery.c @@ -2285,17 +2285,14 @@ static int rk30_adc_battery_probe(struct platform_device *pdev) gSecondsCnt = get_seconds(); /*data = kzalloc(sizeof(*data), GFP_KERNEL);*/ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); - if (data == NULL) { + if (data == NULL) ret = -ENOMEM; - goto err_data_alloc_failed; - } /*pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);*/ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); - if (pdata == NULL) { + if (pdata == NULL) ret = -ENOMEM; - goto err_pdata_alloc_failed; - } + memset(data, 0, sizeof(struct rk30_adc_battery_data)); gBatteryData = data; platform_set_drvdata(pdev, data); @@ -2470,12 +2467,6 @@ err_dcirq_failed: #endif err_io_init: - -err_pdata_alloc_failed: - kfree(pdata); -err_data_alloc_failed: - kfree(data); - printk("rk30_adc_battery: error!\n"); return ret; @@ -2500,8 +2491,6 @@ static int rk30_adc_battery_remove(struct platform_device *pdev) power_supply_unregister(&data ->bat); if (batt_gpio_is_valid(pdata->dc_det_pin)) free_irq(gpio_to_irq(pdata->dc_det_pin), data); - - kfree(data); return 0; } diff --git a/drivers/power/rt5025-battery.c b/drivers/power/rt5025-battery.c index 6b4314e05746..8403b1da02d1 100644 --- a/drivers/power/rt5025-battery.c +++ b/drivers/power/rt5025-battery.c @@ -1716,7 +1716,6 @@ static int rt5025_battery_remove(struct platform_device *pdev) power_supply_unregister(&bi->battery); cancel_delayed_work(&bi->monitor_work); wake_lock_destroy(&bi->monitor_wake_lock); - kfree(bi); RTINFO("\n"); return 0; } diff --git a/drivers/regulator/act8846.c b/drivers/regulator/act8846.c index 8c57878ae700..3042b0000678 100755 --- a/drivers/regulator/act8846.c +++ b/drivers/regulator/act8846.c @@ -954,7 +954,10 @@ static int act8846_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id if (pdev) { act8846->num_regulators = act8846_NUM_REGULATORS; - act8846->rdev = kcalloc(act8846_NUM_REGULATORS,sizeof(struct regulator_dev *), GFP_KERNEL); + act8846->rdev = devm_kcalloc(act8846->dev, + act8846_NUM_REGULATORS, + sizeof(struct regulator_dev *), + GFP_KERNEL); if (!act8846->rdev) { return -ENOMEM; } @@ -1012,9 +1015,7 @@ static int act8846_i2c_remove(struct i2c_client *i2c) for (i = 0; i < act8846->num_regulators; i++) if (act8846->rdev[i]) regulator_unregister(act8846->rdev[i]); - kfree(act8846->rdev); i2c_set_clientdata(i2c, NULL); - kfree(act8846); return 0; } diff --git a/drivers/regulator/act8931.c b/drivers/regulator/act8931.c index 11ae72354c3a..150c9cfc060f 100755 --- a/drivers/regulator/act8931.c +++ b/drivers/regulator/act8931.c @@ -775,9 +775,10 @@ static int act8931_i2c_probe(struct i2c_client *i2c, if (pdata) { act8931->num_regulators = ACT8931_NUM_REGULATORS; - act8931->rdev = kcalloc(ACT8931_NUM_REGULATORS, - sizeof(struct regulator_dev *), - GFP_KERNEL); + act8931->rdev = devm_kcalloc(act8931->dev, + ACT8931_NUM_REGULATORS, + sizeof(struct regulator_dev *), + GFP_KERNEL); if (!act8931->rdev) return -ENOMEM; @@ -857,9 +858,7 @@ static int act8931_i2c_remove(struct i2c_client *i2c) for (i = 0; i < act8931->num_regulators; i++) if (act8931->rdev[i]) regulator_unregister(act8931->rdev[i]); - kfree(act8931->rdev); i2c_set_clientdata(i2c, NULL); - kfree(act8931); return 0; } diff --git a/drivers/rtc/rtc-ricoh619.c b/drivers/rtc/rtc-ricoh619.c index 9b16f28f2835..603fa1303b0e 100755 --- a/drivers/rtc/rtc-ricoh619.c +++ b/drivers/rtc/rtc-ricoh619.c @@ -750,7 +750,7 @@ static int ricoh619_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); // printk(KERN_INFO "PMU: %s register rtc device \n", __func__); - rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, + rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, &ricoh619_rtc_ops, THIS_MODULE); // set interrupt and enable it @@ -800,18 +800,11 @@ static int ricoh619_rtc_probe(struct platform_device *pdev) return 0; fail: - if (!IS_ERR_OR_NULL(rtc->rtc)) - rtc_device_unregister(rtc->rtc); - kfree(rtc); return err; } static int ricoh619_rtc_remove(struct platform_device *pdev) { - struct ricoh619_rtc *rtc = dev_get_drvdata(&pdev->dev); - - rtc_device_unregister(rtc->rtc); - kfree(rtc); return 0; } -- 2.34.1