Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f883def5 authored by Hangbin Liu's avatar Hangbin Liu Committed by Greg Kroah-Hartman
Browse files

net/packet: fix packet_sock xmit return value checking



[ Upstream commit 29e8e659f984be00d75ec5fef4e37c88def72712 ]

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: 1da177e4 ("Linux-2.6.12-rc2")
Reported-by: default avatarFlavio Leitner <fbl@redhat.com>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent e1bc684c
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -2791,7 +2791,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)

		status = TP_STATUS_SEND_REQUEST;
		err = po->xmit(skb);
		if (unlikely(err > 0)) {
		if (unlikely(err != 0)) {
			if (err > 0)
				err = net_xmit_errno(err);
			if (err && __packet_get_status(po, ph) ==
				   TP_STATUS_AVAILABLE) {
@@ -2993,8 +2994,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)
	if (unlikely(err != 0)) {
		if (err > 0)
			err = net_xmit_errno(err);
		if (err)
			goto out_unlock;
	}

	dev_put(dev);