Skip to content

Commit f7dcc5e

Browse files
committed
firewire: net: fix unexpected release of object for asynchronous request packet
The lifetime of object for asynchronous request packet is now maintained by reference counting, while current implementation of firewire-net releases the passed object in the handler. This commit fixes the bug. Reported-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/lkml/Y%2Fymx6WZIAlrtjLc@workstation/ Fixes: 13a55d6 ("firewire: core: use kref structure to maintain lifetime of data for fw_request structure") Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Takashi Sakamoto <[email protected]>
1 parent ac9a786 commit f7dcc5e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

drivers/firewire/net.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -706,21 +706,22 @@ static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r,
706706
int rcode;
707707

708708
if (destination == IEEE1394_ALL_NODES) {
709-
kfree(r);
710-
711-
return;
712-
}
713-
714-
if (offset != dev->handler.offset)
709+
// Although the response to the broadcast packet is not necessarily required, the
710+
// fw_send_response() function should still be called to maintain the reference
711+
// counting of the object. In the case, the call of function just releases the
712+
// object as a result to decrease the reference counting.
713+
rcode = RCODE_COMPLETE;
714+
} else if (offset != dev->handler.offset) {
715715
rcode = RCODE_ADDRESS_ERROR;
716-
else if (tcode != TCODE_WRITE_BLOCK_REQUEST)
716+
} else if (tcode != TCODE_WRITE_BLOCK_REQUEST) {
717717
rcode = RCODE_TYPE_ERROR;
718-
else if (fwnet_incoming_packet(dev, payload, length,
719-
source, generation, false) != 0) {
718+
} else if (fwnet_incoming_packet(dev, payload, length,
719+
source, generation, false) != 0) {
720720
dev_err(&dev->netdev->dev, "incoming packet failure\n");
721721
rcode = RCODE_CONFLICT_ERROR;
722-
} else
722+
} else {
723723
rcode = RCODE_COMPLETE;
724+
}
724725

725726
fw_send_response(card, r, rcode);
726727
}

0 commit comments

Comments
 (0)