Skip to content

Commit 1bf145f

Browse files
author
Stefan Richter
committed
firewire: net: fix unicast reception RCODE in failure paths
The incoming request hander fwnet_receive_packet() expects subsequent datagram handling code to return non-zero on errors. However, almost none of the failure paths did so. Fix them all. (This error reporting is used to send and RCODE_CONFLICT_ERROR to the sender node in such failure cases. Two modes of failure exist: Out of memory, or firewire-net is unaware of any peer node to which a fragment or an ARP packet belongs. However, it is unclear whether a sender can actually make use of such information. A Linux peer apparently can't. Maybe it should all be simplified to void functions.) Reported-by: Julia Lawall <julia@diku.dk> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
1 parent a481e97 commit 1bf145f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/firewire/net.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
579579
if (!peer) {
580580
fw_notify("No peer for ARP packet from %016llx\n",
581581
(unsigned long long)peer_guid);
582-
goto failed_proto;
582+
goto no_peer;
583583
}
584584

585585
/*
@@ -656,15 +656,15 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
656656

657657
return 0;
658658

659-
failed_proto:
659+
no_peer:
660660
net->stats.rx_errors++;
661661
net->stats.rx_dropped++;
662662

663663
dev_kfree_skb_any(skb);
664664
if (netif_queue_stopped(net))
665665
netif_wake_queue(net);
666666

667-
return 0;
667+
return -ENOENT;
668668
}
669669

670670
static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
@@ -701,7 +701,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
701701
fw_error("out of memory\n");
702702
net->stats.rx_dropped++;
703703

704-
return -1;
704+
return -ENOMEM;
705705
}
706706
skb_reserve(skb, (net->hard_header_len + 15) & ~15);
707707
memcpy(skb_put(skb, len), buf, len);
@@ -726,8 +726,10 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
726726
spin_lock_irqsave(&dev->lock, flags);
727727

728728
peer = fwnet_peer_find_by_node_id(dev, source_node_id, generation);
729-
if (!peer)
730-
goto bad_proto;
729+
if (!peer) {
730+
retval = -ENOENT;
731+
goto fail;
732+
}
731733

732734
pd = fwnet_pd_find(peer, datagram_label);
733735
if (pd == NULL) {
@@ -741,7 +743,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
741743
dg_size, buf, fg_off, len);
742744
if (pd == NULL) {
743745
retval = -ENOMEM;
744-
goto bad_proto;
746+
goto fail;
745747
}
746748
peer->pdg_size++;
747749
} else {
@@ -755,9 +757,9 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
755757
pd = fwnet_pd_new(net, peer, datagram_label,
756758
dg_size, buf, fg_off, len);
757759
if (pd == NULL) {
758-
retval = -ENOMEM;
759760
peer->pdg_size--;
760-
goto bad_proto;
761+
retval = -ENOMEM;
762+
goto fail;
761763
}
762764
} else {
763765
if (!fwnet_pd_update(peer, pd, buf, fg_off, len)) {
@@ -768,7 +770,8 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
768770
*/
769771
fwnet_pd_delete(pd);
770772
peer->pdg_size--;
771-
goto bad_proto;
773+
retval = -ENOMEM;
774+
goto fail;
772775
}
773776
}
774777
} /* new datagram or add to existing one */
@@ -794,14 +797,13 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
794797
spin_unlock_irqrestore(&dev->lock, flags);
795798

796799
return 0;
797-
798-
bad_proto:
800+
fail:
799801
spin_unlock_irqrestore(&dev->lock, flags);
800802

801803
if (netif_queue_stopped(net))
802804
netif_wake_queue(net);
803805

804-
return 0;
806+
return retval;
805807
}
806808

807809
static void fwnet_receive_packet(struct fw_card *card, struct fw_request *r,

0 commit comments

Comments
 (0)