Message ID | 20250107054453.2889332-1-joe@pf.is.s.u-tokyo.ac.jp (mailing list archive) |
---|---|
State | New |
Delegated to: | viresh kumar |
Headers | show |
Series | OPP: OF: Fix an OF node leak in _opp_add_static_v2() | expand |
On 07-01-25, 14:44, Joe Hattori wrote: > _opp_add_static_v2() leaks the obtained OF node reference when > _of_opp_alloc_required_opps() fails. Add an of_node_put() call in the > error path. > > Fixes: 3466ea2cd6b6 ("OPP: Don't drop opp->np reference while it is still in use") > Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> > --- > drivers/opp/of.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/opp/of.c b/drivers/opp/of.c > index fd5ed2858258..a24f76f5fd01 100644 > --- a/drivers/opp/of.c > +++ b/drivers/opp/of.c > @@ -926,7 +926,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, > > ret = _of_opp_alloc_required_opps(opp_table, new_opp); > if (ret) > - goto free_opp; > + goto put_node; > > if (!of_property_read_u32(np, "clock-latency-ns", &val)) > new_opp->clock_latency_ns = val; > @@ -976,6 +976,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, > > free_required_opps: > _of_opp_free_required_opps(opp_table, new_opp); > +put_node: > + of_node_put(np); > free_opp: > _opp_free(new_opp); Applied. Thanks.
diff --git a/drivers/opp/of.c b/drivers/opp/of.c index fd5ed2858258..a24f76f5fd01 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -926,7 +926,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, ret = _of_opp_alloc_required_opps(opp_table, new_opp); if (ret) - goto free_opp; + goto put_node; if (!of_property_read_u32(np, "clock-latency-ns", &val)) new_opp->clock_latency_ns = val; @@ -976,6 +976,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table, free_required_opps: _of_opp_free_required_opps(opp_table, new_opp); +put_node: + of_node_put(np); free_opp: _opp_free(new_opp);
_opp_add_static_v2() leaks the obtained OF node reference when _of_opp_alloc_required_opps() fails. Add an of_node_put() call in the error path. Fixes: 3466ea2cd6b6 ("OPP: Don't drop opp->np reference while it is still in use") Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> --- drivers/opp/of.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)