aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@ingics.com>2013-02-12 20:29:45 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-02-13 07:52:18 -0500
commitcbb0ed495ca165a94d66610adf64961f2117ec36 (patch)
tree92723e2f2a6d8d3b47ccadc5e64cb7628a93fc60
parent1f91b6f6c747d3c584a5f37f68f5417bd328d745 (diff)
regulator: s5m8767: Fix dev argument for devm_kzalloc and of_get_regulator_init_data
Use &pdev->dev rather than iodev->dev for devm_kzalloc() and of_get_regulator_init_data(), this fixes memory leak. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--drivers/regulator/s5m8767.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 194b5dd30628..ef0532d56d43 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -515,9 +515,10 @@ static int s5m8767_pmic_dt_parse_ds_gpio(struct sec_pmic_dev *iodev,
515 return 0; 515 return 0;
516} 516}
517 517
518static int s5m8767_pmic_dt_parse_pdata(struct sec_pmic_dev *iodev, 518static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
519 struct sec_platform_data *pdata) 519 struct sec_platform_data *pdata)
520{ 520{
521 struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
521 struct device_node *pmic_np, *regulators_np, *reg_np; 522 struct device_node *pmic_np, *regulators_np, *reg_np;
522 struct sec_regulator_data *rdata; 523 struct sec_regulator_data *rdata;
523 struct sec_opmode_data *rmode; 524 struct sec_opmode_data *rmode;
@@ -538,7 +539,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct sec_pmic_dev *iodev,
538 /* count the number of regulators to be supported in pmic */ 539 /* count the number of regulators to be supported in pmic */
539 pdata->num_regulators = of_get_child_count(regulators_np); 540 pdata->num_regulators = of_get_child_count(regulators_np);
540 541
541 rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * 542 rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
542 pdata->num_regulators, GFP_KERNEL); 543 pdata->num_regulators, GFP_KERNEL);
543 if (!rdata) { 544 if (!rdata) {
544 dev_err(iodev->dev, 545 dev_err(iodev->dev,
@@ -546,7 +547,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct sec_pmic_dev *iodev,
546 return -ENOMEM; 547 return -ENOMEM;
547 } 548 }
548 549
549 rmode = devm_kzalloc(iodev->dev, sizeof(*rmode) * 550 rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) *
550 pdata->num_regulators, GFP_KERNEL); 551 pdata->num_regulators, GFP_KERNEL);
551 if (!rdata) { 552 if (!rdata) {
552 dev_err(iodev->dev, 553 dev_err(iodev->dev,
@@ -570,7 +571,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct sec_pmic_dev *iodev,
570 571
571 rdata->id = i; 572 rdata->id = i;
572 rdata->initdata = of_get_regulator_init_data( 573 rdata->initdata = of_get_regulator_init_data(
573 iodev->dev, reg_np); 574 &pdev->dev, reg_np);
574 rdata->reg_node = reg_np; 575 rdata->reg_node = reg_np;
575 rdata++; 576 rdata++;
576 rmode->id = i; 577 rmode->id = i;
@@ -642,7 +643,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct sec_pmic_dev *iodev,
642 return 0; 643 return 0;
643} 644}
644#else 645#else
645static int s5m8767_pmic_dt_parse_pdata(struct sec_pmic_dev *iodev, 646static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
646 struct sec_platform_data *pdata) 647 struct sec_platform_data *pdata)
647{ 648{
648 return 0; 649 return 0;
@@ -659,7 +660,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
659 int i, ret, size, buck_init; 660 int i, ret, size, buck_init;
660 661
661 if (iodev->dev->of_node) { 662 if (iodev->dev->of_node) {
662 ret = s5m8767_pmic_dt_parse_pdata(iodev, pdata); 663 ret = s5m8767_pmic_dt_parse_pdata(pdev, pdata);
663 if (ret) 664 if (ret)
664 return ret; 665 return ret;
665 } 666 }