[nftables PATCH] cache: check errno before invoking cache_release()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/cache.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/cache.c b/src/cache.c
index f59bba03..ff63e59e 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -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;
 	}
 
-- 
2.31.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux