Skip to content

Commit a277489

Browse files
Abdun Nihaalgregkh
authored andcommitted
OPP: of: Fix potential memory leak in opp_parse_supplies()
commit 69f8883 upstream. The memory allocated for microvolt, microamp and microwatt is not freed in one of the paths in opp_parse_supplies() which returns directly. Fix that by adding a goto to the error unwind ladder. Fixes: 2eedf62 ("OPP: decouple dt properties in opp_parse_supplies()") Cc: stable@vger.kernel.org Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 685fc15 commit a277489

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/opp/of.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
669669
*/
670670
if (unlikely(opp_table->regulator_count == -1)) {
671671
opp_table->regulator_count = 0;
672-
return 0;
672+
goto free_microwatt;
673673
}
674674

675675
for (i = 0, j = 0; i < opp_table->regulator_count; i++) {
@@ -692,6 +692,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
692692
opp->supplies[i].u_watt = microwatt[i];
693693
}
694694

695+
free_microwatt:
695696
kfree(microwatt);
696697
free_microamp:
697698
kfree(microamp);

0 commit comments

Comments
 (0)