Skip to content

Commit 7881cd6

Browse files
Sasha Levintorvalds
authored andcommitted
media: venus: Fix OPP table error handling
The venus driver fails to check if dev_pm_opp_find_freq_{ceil,floor}() returns an error pointer before calling dev_pm_opp_put(). This causes a crash when OPP tables are not present in device tree. Unable to handle kernel access to user memory outside uaccess routines at virtual address 000000000000002e ... pc : dev_pm_opp_put+0x1c/0x4c lr : core_clks_enable+0x4c/0x16c [venus_core] Add IS_ERR() checks before calling dev_pm_opp_put() to avoid dereferencing error pointers. Fixes: b179234 ("media: venus: pm_helpers: use opp-table for the frequency") Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent adf12a3 commit 7881cd6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/media/platform/qcom/venus/pm_helpers.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ static int core_clks_enable(struct venus_core *core)
4848
int ret;
4949

5050
opp = dev_pm_opp_find_freq_ceil(dev, &freq);
51-
dev_pm_opp_put(opp);
51+
if (!IS_ERR(opp))
52+
dev_pm_opp_put(opp);
5253

5354
for (i = 0; i < res->clks_num; i++) {
5455
if (IS_V6(core)) {
@@ -660,7 +661,8 @@ static int decide_core(struct venus_inst *inst)
660661
/*TODO : divide this inst->load by work_route */
661662

662663
opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
663-
dev_pm_opp_put(opp);
664+
if (!IS_ERR(opp))
665+
dev_pm_opp_put(opp);
664666

665667
min_loaded_core(inst, &min_coreid, &min_load, false);
666668
min_loaded_core(inst, &min_lp_coreid, &min_lp_load, true);
@@ -1121,7 +1123,8 @@ static int load_scale_v4(struct venus_inst *inst)
11211123
freq = max(freq_core1, freq_core2);
11221124

11231125
opp = dev_pm_opp_find_freq_floor(dev, &max_freq);
1124-
dev_pm_opp_put(opp);
1126+
if (!IS_ERR(opp))
1127+
dev_pm_opp_put(opp);
11251128

11261129
if (freq > max_freq) {
11271130
dev_dbg(dev, VDBGL "requested clock rate: %lu scaling clock rate : %lu\n",
@@ -1131,7 +1134,8 @@ static int load_scale_v4(struct venus_inst *inst)
11311134
}
11321135

11331136
opp = dev_pm_opp_find_freq_ceil(dev, &freq);
1134-
dev_pm_opp_put(opp);
1137+
if (!IS_ERR(opp))
1138+
dev_pm_opp_put(opp);
11351139

11361140
set_freq:
11371141

0 commit comments

Comments
 (0)