net: Return the correct errno code
authorZheng Yongjun <zhengyongjun3@huawei.com>
Wed, 2 Jun 2021 14:06:40 +0000 (22:06 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 3 Jun 2021 22:13:56 +0000 (15:13 -0700)
When kalloc or kmemdup failed, should return ENOMEM rather than ENOBUF.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/compat.c

index ddd15af..210fc3b 100644 (file)
@@ -177,7 +177,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk,
        if (kcmlen > stackbuf_size)
                kcmsg_base = kcmsg = sock_kmalloc(sk, kcmlen, GFP_KERNEL);
        if (kcmsg == NULL)
-               return -ENOBUFS;
+               return -ENOMEM;
 
        /* Now copy them over neatly. */
        memset(kcmsg, 0, kcmlen);