History

Merge tag 'opp-updates-7.3.rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm

Merge OPP updates for 7.3-rc3 from Viresh Kumar: "- Fix potential multiplication overflow when calculating freq in OPP core (Colin Ian King). - Fix use after free in _update_opp_table_clk() (Peter Griffin). - Use %pe to print symbolic error name (Sumeet Pawnikar)." * tag 'opp-updates-7.3.rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: opp: fix use after free in _update_opp_table_clk() opp: Use %pe to print symbolic error name OPP: of: Fix potential multiplication overflow when calculating freq

Rafael J. Wysocki committed 2 months ago

Commit e06cb122 parents df29080 1f6de652 files · +19 −17Browse files

Unified · Split

2 files
  1. drivers/opp/core.c +16 −14
  2. drivers/opp/of.c +3 −3
drivers/opp/core.c+16−14
@@ -453,8 +453,8 @@ int dev_pm_opp_get_opp_count(struct device *dev) · 452 unmodified lines
453453 _find_opp_table(dev);
454454
455455 if (IS_ERR(opp_table)) {
456− dev_dbg(dev, "%s: OPP table not found (%ld)\n",
457− __func__, PTR_ERR(opp_table));
456+ dev_dbg(dev, "%s: OPP table not found (%pe)\n",
457+ __func__, opp_table);
458458 return PTR_ERR(opp_table);
459459 }
460460
@@ -611,8 +611,8 @@ _find_key(struct device *dev, unsigned long *key, int index, bool available, · 150 unmodified lines
611611 _find_opp_table(dev);
612612
613613 if (IS_ERR(opp_table)) {
614− dev_err(dev, "%s: OPP table not found (%ld)\n", __func__,
615− PTR_ERR(opp_table));
614+ dev_err(dev, "%s: OPP table not found (%pe)\n", __func__,
615+ opp_table);
616616 return ERR_CAST(opp_table);
617617 }
618618
@@ -722,8 +722,8 @@ struct dev_pm_opp *dev_pm_opp_find_key_exact(struct device *dev, · 103 unmodified lines
722722 struct opp_table *opp_table __free(put_opp_table) = _find_opp_table(dev);
723723
724724 if (IS_ERR(opp_table)) {
725− dev_err(dev, "%s: OPP table not found (%ld)\n", __func__,
726− PTR_ERR(opp_table));
725+ dev_err(dev, "%s: OPP table not found (%pe)\n", __func__,
726+ opp_table);
727727 return ERR_CAST(opp_table);
728728 }
729729
@@ -1036,8 +1036,8 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg, · 306 unmodified lines
10361036
10371037 /* Regulator not available for device */
10381038 if (IS_ERR(reg)) {
1039− dev_dbg(dev, "%s: regulator not available: %ld\n", __func__,
1040− PTR_ERR(reg));
1039+ dev_dbg(dev, "%s: regulator not available: %pe\n", __func__,
1040+ reg);
10411041 return 0;
10421042 }
10431043
@@ -1448,8 +1448,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) · 404 unmodified lines
14481448 temp_freq = freq;
14491449 opp = _find_freq_ceil(opp_table, &temp_freq);
14501450 if (IS_ERR(opp)) {
1451− dev_err(dev, "%s: failed to find OPP for freq %lu (%ld)\n",
1452− __func__, freq, PTR_ERR(opp));
1451+ dev_err(dev, "%s: failed to find OPP for freq %lu (%pe)\n",
1452+ __func__, freq, opp);
14531453 return PTR_ERR(opp);
14541454 }
14551455
@@ -1581,6 +1581,8 @@ static struct opp_table *_update_opp_table_clk(struct device *dev, · 125 unmodified lines
15811581 struct opp_table *opp_table,
15821582 bool getclk)
15831583 {
1584+ int ret;
1585+
15841586 /*
15851587 * Return early if we don't need to get clk or we have already done it
15861588 * earlier.
@@ -1607,9 +1609,9 @@ static struct opp_table *_update_opp_table_clk(struct device *dev, · 20 unmodified lines
16071609 opp_table->clk = clk_get_optional(dev, NULL);
16081610
16091611 if (IS_ERR(opp_table->clk)) {
1612+ ret = dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n");
16101613 dev_pm_opp_put_opp_table(opp_table);
1611− dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n");
1612− return ERR_CAST(opp_table->clk);
1614+ return ERR_PTR(ret);
16131615 }
16141616
16151617 if (opp_table->clk)
@@ -2869,8 +2871,8 @@ static int _opp_set_availability(struct device *dev, unsigned long freq, · 1253 unmodified lines
28692871 struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp;
28702872
28712873 if (IS_ERR(opp_table)) {
2872− dev_warn(dev, "%s: Device OPP not found (%ld)\n", __func__,
2873− PTR_ERR(opp_table));
2874+ dev_warn(dev, "%s: Device OPP not found (%pe)\n", __func__,
2875+ opp_table);
28742876 return PTR_ERR(opp_table);
28752877 }
28762878
drivers/opp/of.c+3−3
@@ -1039,7 +1039,7 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) · 1038 unmodified lines
10391039
10401040 val = prop->value;
10411041 while (nr) {
1042− unsigned long freq = be32_to_cpup(val++) * 1000;
1042+ unsigned long freq = (unsigned long)be32_to_cpup(val++) * 1000;
10431043 unsigned long volt = be32_to_cpup(val++);
10441044 struct dev_pm_opp_data data = {
10451045 .freq = freq,
@@ -1345,8 +1345,8 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) · 299 unmodified lines
13451345 _find_table_of_opp_np(required_np);
13461346
13471347 if (IS_ERR(opp_table)) {
1348− pr_err("%s: Failed to find required OPP table %pOF: %ld\n",
1349− __func__, np, PTR_ERR(opp_table));
1348+ pr_err("%s: Failed to find required OPP table %pOF: %pe\n",
1349+ __func__, np, opp_table);
13501350 return PTR_ERR(opp_table);
13511351 }
13521352