]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
cache: check errno before invoking cache_release()
authorMarco Oliverio <marco.oliverio@tanaza.com>
Thu, 13 May 2021 14:10:32 +0000 (16:10 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 13 May 2021 23:30:09 +0000 (01:30 +0200)
if genid changes during cache_init(), check_genid() sets errno to EINTR to force
a re-init of the cache.

cache_release() may inadvertly change errno by calling free().  Indeed free()
may invoke madvise() that changes errno to ENOSYS on system where kernel is
configured without support for this syscall.

Signed-off-by: Marco Oliverio <marco.oliverio@tanaza.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/cache.c

index f59bba03b81e33320628539f4754562d7277c48a..ff63e59eaafc84c3246907257e66791fbe6b1761 100644 (file)
@@ -747,10 +747,12 @@ replay:
 
        ret = nft_cache_init(&ctx, flags);
        if (ret < 0) {
-               nft_cache_release(cache);
-               if (errno == EINTR)
+               if (errno == EINTR) {
+                       nft_cache_release(cache);
                        goto replay;
+               }
 
+               nft_cache_release(cache);
                return -1;
        }