Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1452388
| From | Michael Ellerman <mpe@ellerman.id.au> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() |
| Date | 2016-07-29 13:40 +0200 |
| Message-ID | <s0eiZ-42k-9@gated-at.bofh.it> (permalink) |
| References | <rZsR3-5wS-15@gated-at.bofh.it> <s077P-7Eh-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Andrew Donnellan <andrew.donnellan@au1.ibm.com> writes: > Rewrite the cxl_guest_init_afu() loop in cxl_of_probe() to use > for_each_child_of_node() rather than a hand-coded for loop. > > Remove the useless of_node_put(afu_np) call after the loop, where it's > guaranteed that afu_np == NULL. > > Reported-by: SF Markus Elfring <elfring@users.sourceforge.net> > Reported-by: Julia Lawall <julia.lawall@lip6.fr> > Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com> > > --- > > Checked the of_node_put() with Fred, he thinks it was probably just left > over from an earlier private version of the code and we can just get rid of > it. But who does keep a reference on the device_node? I can't see it anywhere. Which means in theory the device_node can be freed out from under you. You have a reference for afu_np as part of for_each_child_of_node(), but it's dropped as soon as you go around the loop. The typical pattern would be that cxl_guest_init_afu() takes an additional reference once it's done all its setup and can't fail. That way at the end of the loop when the loop construct has dropped all references, the nodes you actually init'ed have their reference count incremented by 1. cheers
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] cxl: Delete an unnecessary check before the function call "of_node_put" Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-07-27 11:00 +0200
[PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() Andrew Donnellan <andrew.donnellan@au1.ibm.com> - 2016-07-29 06:00 +0200
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() Frederic Barrat <fbarrat@linux.vnet.ibm.com> - 2016-07-29 09:50 +0200
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() Julia Lawall <julia.lawall@lip6.fr> - 2016-07-29 10:50 +0200
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() walter harms <wharms@bfs.de> - 2016-07-29 10:50 +0200
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() Michael Ellerman <mpe@ellerman.id.au> - 2016-07-29 13:40 +0200
Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() Frederic Barrat <fbarrat@linux.vnet.ibm.com> - 2016-08-01 19:40 +0200
csiph-web