Re: [PATCH v4 0/7] OPP: Add support to find OPP for a set of keys

From: Viresh Kumar
Date: Tue Aug 26 2025 - 01:36:25 EST


On 26-08-25, 10:50, Viresh Kumar wrote:
> On 25-08-25, 22:14, Wasim Nazir wrote:
> > Kernel log:
> > Unable to handle kernel NULL pointer dereference at virtual address 0000000000000016
> > ...
> > Call trace:
> > _read_bw+0x0/0x10 (P)
> > _find_key+0xb8/0x194
> > dev_pm_opp_find_bw_floor+0x54/0x8c
> > bwmon_intr_thread+0x84/0x284 [icc_bwmon]
> > irq_thread_fn+0x2c/0xa8
> > irq_thread+0x174/0x334
> > kthread+0x134/0x208
> > ret_from_fork+0x10/0x20
>
> Hmm, this happened because it is possible for the `opp` to be invalid
> (error) even if `_compare_floor()` returned true, if the target key is
> lower than the lowest freq of the table.
>
> Dropped the patch for now anyway.

Can you help me testing this over your failing branch please ?

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 81fb7dd7f323..5b24255733b5 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -554,10 +554,10 @@ static struct dev_pm_opp *_opp_table_find_key(struct opp_table *opp_table,
list_for_each_entry(temp_opp, &opp_table->opp_list, node) {
if (temp_opp->available == available) {
if (compare(&opp, temp_opp, read(temp_opp, index), *key)) {
- *key = read(opp, index);
-
- /* Increment the reference count of OPP */
- dev_pm_opp_get(opp);
+ if (!IS_ERR(opp)) {
+ *key = read(opp, index);
+ dev_pm_opp_get(opp);
+ }
break;
}
}

--
viresh