git: cf4bb6f4aa7f - stable/15 - libnetmap: fix error path in nmport_extmem_from_file

Jose Luis Duran <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a66d42c.1bee9.77c38882__10154.826850497$1785123916$gmane$org@gitrepo.freebsd.org>
The branch stable/15 has been updated by jlduran:

URL: https://cgit.FreeBSD.org/src/commit/?id=cf4bb6f4aa7f39e66434f73d65bd08261deea792

commit cf4bb6f4aa7f39e66434f73d65bd08261deea792
Author:     Jose Luis Duran <[email protected]>
AuthorDate: 2026-07-13 12:23:14 +0000
Commit:     Jose Luis Duran <[email protected]>
CommitDate: 2026-07-27 03:40:43 +0000

    libnetmap: fix error path in nmport_extmem_from_file
    
    Reviewed by:    zlei, vmaffione
    Obtained from:  https://github.com/luigirizzo/netmap/commit/b52a2bcae35e56548acfb0849b248a1e4b0c0c3b
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D58150
    
    (cherry picked from commit fcaf15e54162fe14483fdf4ac28c67c51e424441)
---
 lib/libnetmap/nmport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/libnetmap/nmport.c b/lib/libnetmap/nmport.c
index ec9c6136f0f8..c892c94db32e 100644
--- a/lib/libnetmap/nmport.c
+++ b/lib/libnetmap/nmport.c
@@ -198,6 +198,7 @@ nmport_extmem_from_file(struct nmport_d *d, const char *fname)
 		errno = ENOMEM;
 		goto fail;
 	}
+	clnup->up.cleanup = NULL;
 
 	fd = open(fname, O_RDWR);
 	if (fd < 0) {
@@ -215,6 +216,7 @@ nmport_extmem_from_file(struct nmport_d *d, const char *fname)
 		goto fail;
 	}
 	close(fd);
+	fd = -1;
 
 	clnup->p = p;
 	clnup->size = mapsize;
@@ -230,7 +232,7 @@ fail:
 	if (fd >= 0)
 		close(fd);
 	if (clnup != NULL) {
-		if (clnup->p != MAP_FAILED)
+		if (clnup->up.cleanup != NULL)
 			nmport_pop_cleanup(d);
 		else
 			nmctx_free(ctx, clnup);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.