Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le 29/07/2016 à 13:38, Michael Ellerman a écrit :
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.


We don't keep a reference on the AFU device_node. Once we've read the config of the AFU, the AFU device_node is never accessed again. So I guess it's possible (though unexpected) that it's freed from under us, but it should not affect the driver.

The AFU is really dependent on the adapter itself, which is one level up in the device tree, and for which we create a device through of_platform_device_create(). The properties under the AFU device node are read directly from the PCI config space in the bare-metal case, where the cxl adapter is a PCI device.

Do we really have a problem here?

  Fred

--
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



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux