net/packet: fix packet_sock xmit return value checking
authorHangbin Liu <liuhangbin@gmail.com>
Thu, 14 Apr 2022 08:49:25 +0000 (16:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 11:15:29 +0000 (13:15 +0200)
commitfe90cb452e4cbd25b207db2e17ba1dea933cf3d3
treed009e17a3408ccf40bcc001cf9c1457335886554
parent2c89b4d022dafaac7fd167ecbc9f77d68578f124
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: 1da177e4c3f4 ("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>
net/packet/af_packet.c