mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
net/packet: fix packet_sock xmit return value checking
[ Upstream commit29e8e659f9
] 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 <fbl@redhat.com> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2c89b4d022
commit
fe90cb452e
1 changed files with 9 additions and 4 deletions
|
@ -2829,7 +2829,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
|
||||||
|
|
||||||
status = TP_STATUS_SEND_REQUEST;
|
status = TP_STATUS_SEND_REQUEST;
|
||||||
err = po->xmit(skb);
|
err = po->xmit(skb);
|
||||||
if (unlikely(err > 0)) {
|
if (unlikely(err != 0)) {
|
||||||
|
if (err > 0)
|
||||||
err = net_xmit_errno(err);
|
err = net_xmit_errno(err);
|
||||||
if (err && __packet_get_status(po, ph) ==
|
if (err && __packet_get_status(po, ph) ==
|
||||||
TP_STATUS_AVAILABLE) {
|
TP_STATUS_AVAILABLE) {
|
||||||
|
@ -3029,8 +3030,12 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
|
||||||
skb->no_fcs = 1;
|
skb->no_fcs = 1;
|
||||||
|
|
||||||
err = po->xmit(skb);
|
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;
|
goto out_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
dev_put(dev);
|
dev_put(dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue