Skip to content

Commit 8d1ed7d

Browse files
ian-abbottgregkh
authored andcommitted
fpga: region: release of_parse_phandle nodes after use
commit 0f5eb15 upstream. Both fpga_region_get_manager() and fpga_region_get_bridges() call of_parse_phandle(), but nothing calls of_node_put() on the returned struct device_node pointers. Make sure to do that to stop their reference counters getting out of whack. Fixes: 0fa20cd ("fpga: fpga-region: device tree control for FPGA") Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Alan Tull <atull@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a252f37 commit 8d1ed7d

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/fpga/fpga-region.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static struct fpga_manager *fpga_region_get_manager(struct fpga_region *region)
147147
mgr_node = of_parse_phandle(np, "fpga-mgr", 0);
148148
if (mgr_node) {
149149
mgr = of_fpga_mgr_get(mgr_node);
150+
of_node_put(mgr_node);
150151
of_node_put(np);
151152
return mgr;
152153
}
@@ -192,23 +193,29 @@ static int fpga_region_get_bridges(struct fpga_region *region,
192193
parent_br = region_np->parent;
193194

194195
/* If overlay has a list of bridges, use it. */
195-
if (of_parse_phandle(overlay, "fpga-bridges", 0))
196+
br = of_parse_phandle(overlay, "fpga-bridges", 0);
197+
if (br) {
198+
of_node_put(br);
196199
np = overlay;
197-
else
200+
} else {
198201
np = region_np;
202+
}
199203

200204
for (i = 0; ; i++) {
201205
br = of_parse_phandle(np, "fpga-bridges", i);
202206
if (!br)
203207
break;
204208

205209
/* If parent bridge is in list, skip it. */
206-
if (br == parent_br)
210+
if (br == parent_br) {
211+
of_node_put(br);
207212
continue;
213+
}
208214

209215
/* If node is a bridge, get it and add to list */
210216
ret = fpga_bridge_get_to_list(br, region->info,
211217
&region->bridge_list);
218+
of_node_put(br);
212219

213220
/* If any of the bridges are in use, give up */
214221
if (ret == -EBUSY) {

0 commit comments

Comments
 (0)