fix: firewire: report_lost_node: unconditional fw_node_put after conditional fw_node_event causes excess put
Subsystems (2)
PATCH 1/1 fix: firewire: report_lost_node: unconditional fw_node_put after conditional fw_node_event causes excess put
report_lost_node unconditionally calls fw_node_put after fw_node_event,
but fw_node_event does not unconditionally acquire a reference. Since for_each_fw_node already holds a reference on the node during traversal, the extra fw_node_put over-decrements the refcount. The sibling callback report_found_node does not call fw_node_put, confirming the extra put is erroneous.
--- drivers/firewire/core-topology.c | 1 - 1 file changed, 1 deletion(-)
drivers/firewire/core-topology.c +0 -1
@@ -298,7 +298,6 @@ static void report_lost_node(struct fw_card *card, struct fw_node *node, struct fw_node *parent) {fw_node_event (card ,node ,FW_NODE_DESTROYED ); -fw_node_put (node);/* Topology has changed - reset bus manager retry counter */ card->bm_retries =0 ;
Signature · 1 line
2.39.5 (Apple Git-154)
Takashi Sakamoto
maintainerHi,
Thanks for the patch.
Quoted 7 lines · WenTao Liang
report_lost_nodeunconditionally callsfw_node_putafterfw_node_event,
butfw_node_eventdoes not unconditionally acquire a reference. Sincefor_each_fw_nodealready holds a reference on the node during traversal, the extrafw_node_putover-decrements the refcount. The sibling callbackreport_found_nodedoes not callfw_node_put, confirming the extra put is erroneous.
Quoted 6 lines
Fixes 3038e353cfaf ("firewire: Add core firewire stack.")Signed-off-by WenTao Liang <[email protected]>--- drivers/firewire/core-topology.c | 1 - 1 file changed, 1 deletion(-)
As you note, in for_each_fw_node(), the reference count is incremented for safe traversing over the topology tree once, and it is decremented surely at the end. So the decrement of reference count in report_lost_node() is the different purpose.
drivers/firewire/core-topology.c static void report_lost_node(struct fw_card *card, · line 301
Quoted 9 lines
drivers/firewire/core-topology.c +0
-1@@ -298,7 +298,6 @@ static void report_lost_node(struct fw_card *card, struct fw_node *node, struct fw_node *parent) {fw_node_event (card ,node ,FW_NODE_DESTROYED ); -fw_node_put (node);
It corresponds to the initial increment of reference count when creating the node instance. It is the part of node removal process in the tree, and is required just in the line.
Quoted 4 lines
drivers/firewire/core-topology.c +0
-1/* Topology has changed - reset bus manager retry counter */ card->bm_retries =0 ; --2.39.5 (Apple Git-154)
Thanks
Takashi Sakamoto