mbox series

[net,0/2] Get the device_node before calling of_find_node_by_name()

Message ID 20241024015909.58654-1-zhangzekun11@huawei.com (mailing list archive)
Headers show
Series Get the device_node before calling of_find_node_by_name() | expand

Message

zhangzekun (A) Oct. 24, 2024, 1:59 a.m. UTC
of_find_node_by_name() will decrease the refount of the device node.
Get the device_node before call to it.

Zhang Zekun (2):
  net: bcmasp: Add missing of_node_get() before of_find_node_by_name()
  net: pse-pd: Add missing of_node_get() before of_find_node_by_name()

 drivers/net/ethernet/broadcom/asp2/bcmasp.c | 1 +
 drivers/net/pse-pd/tps23881.c               | 1 +
 2 files changed, 2 insertions(+)

Comments

Jakub Kicinski Oct. 31, 2024, 1:17 a.m. UTC | #1
On Thu, 24 Oct 2024 09:59:07 +0800 Zhang Zekun wrote:
> of_find_node_by_name() will decrease the refount of the device node.
> Get the device_node before call to it.

Doing some quick grepping I think Andrew is completely right.
Most callers either get this wrong or call get() immediately prior.
Maybe add a new helper with more suitable semantics?

The goal is not to fix the bugs but to prevent them in the first place.