Andrew Donnellan <andrew.donnellan@xxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxx> > Reported-by: Julia Lawall <julia.lawall@xxxxxxx> > Signed-off-by: Andrew Donnellan <andrew.donnellan@xxxxxxxxxxx> > > --- > > 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 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html