Skip to content

Commit 00635b8

Browse files
author
Stefan Richter
committed
firewire: net: better FIFO address range check and rcodes
The AR req handler should not check the generation; higher level code is the better place to handle bus generation changes. The target node ID just needs to be checked for not being the "all nodes" address; in this case don't handle the request and don't respond. Use Address_Error and Type_Error rcodes as appropriate. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent b01b4ba commit 00635b8

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

‎drivers/firewire/net.c‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -810,29 +810,27 @@ static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r,
810810
int speed, unsigned long long offset, void *payload,
811811
size_t length, void *callback_data)
812812
{
813-
struct fwnet_device *dev;
814-
int status;
813+
struct fwnet_device *dev = callback_data;
814+
int rcode;
815815

816-
dev = callback_data;
817-
if (tcode != TCODE_WRITE_BLOCK_REQUEST
818-
|| destination != card->node_id /* <- FIXME */
819-
|| generation != card->generation /* <- FIXME */
820-
|| offset != dev->handler.offset) {
821-
fw_send_response(card, r, RCODE_CONFLICT_ERROR);
816+
if (destination == IEEE1394_ALL_NODES) {
817+
kfree(r);
822818

823819
return;
824820
}
825821

826-
status = fwnet_incoming_packet(dev, payload, length,
827-
source, generation, false);
828-
if (status != 0) {
822+
if (offset != dev->handler.offset)
823+
rcode = RCODE_ADDRESS_ERROR;
824+
else if (tcode != TCODE_WRITE_BLOCK_REQUEST)
825+
rcode = RCODE_TYPE_ERROR;
826+
else if (fwnet_incoming_packet(dev, payload, length,
827+
source, generation, false) != 0) {
829828
fw_error("Incoming packet failure\n");
830-
fw_send_response(card, r, RCODE_CONFLICT_ERROR);
831-
832-
return;
833-
}
829+
rcode = RCODE_CONFLICT_ERROR;
830+
} else
831+
rcode = RCODE_COMPLETE;
834832

835-
fw_send_response(card, r, RCODE_COMPLETE);
833+
fw_send_response(card, r, rcode);
836834
}
837835

838836
static void fwnet_receive_broadcast(struct fw_iso_context *context,

0 commit comments

Comments
 (0)