]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: ieee802154: fix error return code in dgram_bind()
authorWei Yongjun <weiyongjun1@huawei.com>
Mon, 19 Sep 2022 16:08:30 +0000 (16:08 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Nov 2022 14:56:54 +0000 (23:56 +0900)
commit 3e2b802c904629c2b0546eb538f15eaeccb91b24 upstream.

Fix to return error code -EINVAL from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 891afbcca1ec ("net/ieee802154: fix uninit value bug in dgram_sendmsg")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20220919160830.1436109-1-weiyongjun@huaweicloud.com
Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ieee802154/socket.c

index 6d6c285817706b2efe346c7a52c69b58987079f4..ce5f25c89dfaf9118df514901081730b94fbd6fb 100644 (file)
@@ -507,8 +507,10 @@ static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len)
        if (err < 0)
                goto out;
 
-       if (addr->family != AF_IEEE802154)
+       if (addr->family != AF_IEEE802154) {
+               err = -EINVAL;
                goto out;
+       }
 
        ieee802154_addr_from_sa(&haddr, &addr->addr);
        dev = ieee802154_get_dev(sock_net(sk), &haddr);