[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220401120325.820763-1-krzysztof.kozlowski@linaro.org>
Date: Fri, 1 Apr 2022 14:03:25 +0200
From: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
To: Viresh Kumar <vireshk@...nel.org>, Nishanth Menon <nm@...com>,
Stephen Boyd <sboyd@...nel.org>,
Dmitry Osipenko <digetx@...il.com>, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: [PATCH] PM: opp: Fix NULL pointer exception on a v2 table combined with v1 opps
dev_pm_opp_add() adds a v1 OPP. If the Devicetree contains an OPP v2
table with required-opps, but the driver uses dev_pm_opp_add(), the
table might have required_opp_count!=0 but the opp->required_opps will
be NULL. This leads to NULL pointer exception, e.g. with ufs-qcom.c
driver and v2 OPP table in DTS:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
...
Call trace:
_required_opps_available+0x20/0x80
_opp_add_v1+0xa8/0x110
dev_pm_opp_add+0x54/0xcc
ufshcd_async_scan+0x190/0x31c
async_run_entry_fn+0x38/0x144
Fixes: cf65948d62c6 ("opp: Filter out OPPs based on availability of a required-OPP")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
---
drivers/opp/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 740407252298..d21b7e7e3f9f 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -1760,7 +1760,9 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp,
if (lazy_linking_pending(opp_table))
return 0;
- _required_opps_available(new_opp, opp_table->required_opp_count);
+ /* No required_opps for v1 bindings OPP */
+ if (new_opp->required_opps)
+ _required_opps_available(new_opp, opp_table->required_opp_count);
return 0;
}
--
2.32.0
Powered by blists - more mailing lists