net: qrtr: fix error return code of qrtr_sendmsg()

When sock_alloc_send_skb() returns NULL to skb, no error return code of
qrtr_sendmsg() is assigned.
To fix this bug, rc is assigned with -ENOMEM in this case.

Fixes: 194ccc8829 ("net: qrtr: Support decoding incoming v2 packets")
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jia-Ju Bai 2021-03-08 01:13:55 -08:00 committed by David S. Miller
parent 27ab92d999
commit 179d0ba0c4
1 changed files with 3 additions and 1 deletions

View File

@ -958,8 +958,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
plen = (len + 3) & ~3; plen = (len + 3) & ~3;
skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_MAX_SIZE, skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_MAX_SIZE,
msg->msg_flags & MSG_DONTWAIT, &rc); msg->msg_flags & MSG_DONTWAIT, &rc);
if (!skb) if (!skb) {
rc = -ENOMEM;
goto out_node; goto out_node;
}
skb_reserve(skb, QRTR_HDR_MAX_SIZE); skb_reserve(skb, QRTR_HDR_MAX_SIZE);