aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2011-05-13 02:54:06 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2011-05-27 05:49:09 -0400
commit6be6e96fe90962171f31c099a5e7c28a49a0d0ae (patch)
tree3fe77e25d2375db4c2ce92043d7d0a83c007fbd1 /drivers/regulator
parent77fa44d0e10711e899788c58fe53f8f7b18c7f67 (diff)
regulator: Fix memory leak in max8998_pmic_probe failure path
Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/max8998.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index f57e9c42fdb4..41a1495eec2b 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -732,13 +732,15 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
732 if (!pdata->buck1_set1) { 732 if (!pdata->buck1_set1) {
733 printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); 733 printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n");
734 WARN_ON(!pdata->buck1_set1); 734 WARN_ON(!pdata->buck1_set1);
735 return -EIO; 735 ret = -EIO;
736 goto err_free_mem;
736 } 737 }
737 /* Check if SET2 is not equal to 0 */ 738 /* Check if SET2 is not equal to 0 */
738 if (!pdata->buck1_set2) { 739 if (!pdata->buck1_set2) {
739 printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); 740 printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n");
740 WARN_ON(!pdata->buck1_set2); 741 WARN_ON(!pdata->buck1_set2);
741 return -EIO; 742 ret = -EIO;
743 goto err_free_mem;
742 } 744 }
743 745
744 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); 746 gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
@@ -758,7 +760,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
758 max8998->buck1_vol[0] = i; 760 max8998->buck1_vol[0] = i;
759 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i); 761 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE1, i);
760 if (ret) 762 if (ret)
761 return ret; 763 goto err_free_mem;
762 764
763 /* Set predefined value for BUCK1 register 2 */ 765 /* Set predefined value for BUCK1 register 2 */
764 i = 0; 766 i = 0;
@@ -770,7 +772,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
770 max8998->buck1_vol[1] = i; 772 max8998->buck1_vol[1] = i;
771 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i); 773 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE2, i);
772 if (ret) 774 if (ret)
773 return ret; 775 goto err_free_mem;
774 776
775 /* Set predefined value for BUCK1 register 3 */ 777 /* Set predefined value for BUCK1 register 3 */
776 i = 0; 778 i = 0;
@@ -782,7 +784,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
782 max8998->buck1_vol[2] = i; 784 max8998->buck1_vol[2] = i;
783 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i); 785 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE3, i);
784 if (ret) 786 if (ret)
785 return ret; 787 goto err_free_mem;
786 788
787 /* Set predefined value for BUCK1 register 4 */ 789 /* Set predefined value for BUCK1 register 4 */
788 i = 0; 790 i = 0;
@@ -794,7 +796,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
794 max8998->buck1_vol[3] = i; 796 max8998->buck1_vol[3] = i;
795 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i); 797 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK1_VOLTAGE4, i);
796 if (ret) 798 if (ret)
797 return ret; 799 goto err_free_mem;
798 800
799 } 801 }
800 802
@@ -803,7 +805,8 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
803 if (!pdata->buck2_set3) { 805 if (!pdata->buck2_set3) {
804 printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); 806 printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n");
805 WARN_ON(!pdata->buck2_set3); 807 WARN_ON(!pdata->buck2_set3);
806 return -EIO; 808 ret = -EIO;
809 goto err_free_mem;
807 } 810 }
808 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); 811 gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
809 gpio_direction_output(pdata->buck2_set3, 812 gpio_direction_output(pdata->buck2_set3,
@@ -818,7 +821,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
818 max8998->buck2_vol[0] = i; 821 max8998->buck2_vol[0] = i;
819 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i); 822 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE1, i);
820 if (ret) 823 if (ret)
821 return ret; 824 goto err_free_mem;
822 825
823 /* BUCK2 register 2 */ 826 /* BUCK2 register 2 */
824 i = 0; 827 i = 0;
@@ -830,7 +833,7 @@ static __devinit int max8998_pmic_probe(struct platform_device *pdev)
830 max8998->buck2_vol[1] = i; 833 max8998->buck2_vol[1] = i;
831 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i); 834 ret = max8998_write_reg(i2c, MAX8998_REG_BUCK2_VOLTAGE2, i);
832 if (ret) 835 if (ret)
833 return ret; 836 goto err_free_mem;
834 } 837 }
835 838
836 for (i = 0; i < pdata->num_regulators; i++) { 839 for (i = 0; i < pdata->num_regulators; i++) {
@@ -860,6 +863,7 @@ err:
860 if (rdev[i]) 863 if (rdev[i])
861 regulator_unregister(rdev[i]); 864 regulator_unregister(rdev[i]);
862 865
866err_free_mem:
863 kfree(max8998->rdev); 867 kfree(max8998->rdev);
864 kfree(max8998); 868 kfree(max8998);
865 869