]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: qrtr: fix error return code of qrtr_sendmsg()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Mon, 8 Mar 2021 09:13:55 +0000 (01:13 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Mar 2021 23:02:53 +0000 (15:02 -0800)
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: e9757df91305 ("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>
net/qrtr/qrtr.c

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