mirror of
https://github.com/torvalds/linux.git
synced 2026-10-07 05:31:08 -04:00
net/packet: fix packet_sock xmit return value checking
packet_sock xmit could be dev_queue_xmit, which also returns negative
errors. So only checking positive errors is not enough, or userspace
sendmsg may return success while packet is not send out.
Move the net_xmit_errno() assignment in the braces as checkpatch.pl said
do not use assignment in if condition.
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: Flavio Leitner <[email protected]>
Signed-off-by: Hangbin Liu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
1 parent
1a74e99323
commit
29e8e659f9
1 file changed
+9
-4
@@ -2858,8 +2858,9 @@ tpacket_error:
|
||||
|
||||
status = TP_STATUS_SEND_REQUEST;
|
||||
err = po->xmit(skb);
|
||||
if (unlikely(err > 0)) {
|
||||
err = net_xmit_errno(err);
|
||||
if (unlikely(err != 0)) {
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
if (err && __packet_get_status(po, ph) ==
|
||||
TP_STATUS_AVAILABLE) {
|
||||
/* skb was destructed already */
|
||||
@@ -3060,8 +3061,12 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
|
||||
skb->no_fcs = 1;
|
||||
|
||||
err = po->xmit(skb);
|
||||
if (err > 0 && (err = net_xmit_errno(err)) != 0)
|
||||
goto out_unlock;
|
||||
if (unlikely(err != 0)) {
|
||||
if (err > 0)
|
||||
err = net_xmit_errno(err);
|
||||
if (err)
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
dev_put(dev);
|
||||
|
||||
|
||||
Reference in new issue
Block a user