]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
sandbox: missing return value checks in eth-raw-os
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 7 Jan 2024 08:27:12 +0000 (09:27 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 12 Apr 2024 14:53:31 +0000 (08:53 -0600)
We should check the return value of fcntl().

Addresses-Coverity-ID: 131108 ("Unchecked return value from library")
Addresses-Coverity-ID: 131109 ("Unchecked return value from library")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
arch/sandbox/cpu/eth-raw-os.c

index 92c35aed95dd984e4581ab93c685e31e050b9bb7..39ea3b3f0128fe4af877a4dc55e5bd2d2e2c2192 100644 (file)
@@ -105,7 +105,12 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv *priv,
 
        /* Make the socket non-blocking */
        flags = fcntl(priv->sd, F_GETFL, 0);
-       fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+       ret = fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+       if (ret == -1) {
+               printf("Failed to make socket non-blocking: %d %s\n", errno,
+                      strerror(errno));
+               return -errno;
+       }
 
        /* Enable promiscuous mode to receive responses meant for us */
        mr.mr_ifindex = device->sll_ifindex;
@@ -172,7 +177,12 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
 
        /* Make the socket non-blocking */
        flags = fcntl(priv->sd, F_GETFL, 0);
-       fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+       ret = fcntl(priv->sd, F_SETFL, flags | O_NONBLOCK);
+       if (ret == -1) {
+               printf("Failed to make socket non-blocking: %d %s\n", errno,
+                      strerror(errno));
+               return -errno;
+       }
 
        /* Include the UDP/IP headers on send and receive */
        ret = setsockopt(priv->sd, IPPROTO_IP, IP_HDRINCL, &one,