]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: check return value of iproute_flush_cache() in irpoute.c
authorAnton Moryakov <ant.v.moryakov@gmail.com>
Mon, 17 Feb 2025 16:21:50 +0000 (19:21 +0300)
committerDavid Ahern <dsahern@kernel.org>
Wed, 19 Feb 2025 15:45:50 +0000 (15:45 +0000)
Static analyzer reported:
Return value of function 'iproute_flush_cache', called at iproute.c:1732,
is not checked. The return value is obtained from function 'open64' and possibly contains an error code.

Corrections explained:
The function iproute_flush_cache() may return an error code, which was
previously ignored. This could lead to unexpected behavior if the cache
flush fails. Added error handling to ensure the function fails gracefully
when iproute_flush_cache() returns an error.

Triggers found by static analyzer Svace.

Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iproute.c

index e1fe26ce05d03cbf0e3d687de873809b95f8a50d..0e2c171f4b8e28875b81dd023ddc05a0c96c67ee 100644 (file)
@@ -1729,7 +1729,10 @@ static int iproute_flush(int family, rtnl_filter_t filter_fn)
 
        if (filter.cloned) {
                if (family != AF_INET6) {
-                       iproute_flush_cache();
+                       ret = iproute_flush_cache();
+                       if (ret < 0)
+                               return ret;
+
                        if (show_stats)
                                printf("*** IPv4 routing cache is flushed.\n");
                }