The branch main has been updated by hselasky:

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

commit 2ca43c3dba1b818db9245027c87fddfc9d4be0a6
Author:     Hans Petter Selasky <hsela...@freebsd.org>
AuthorDate: 2022-07-13 15:54:24 +0000
Commit:     Hans Petter Selasky <hsela...@freebsd.org>
CommitDate: 2022-07-20 08:41:11 +0000

    cuse(3): Make cuse_vmfree() NULL safe.
    
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 lib/libcuse/cuse.3     | 1 +
 lib/libcuse/cuse_lib.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/libcuse/cuse.3 b/lib/libcuse/cuse.3
index 74888a687be8..aab8ebb4d4f4 100644
--- a/lib/libcuse/cuse.3
+++ b/lib/libcuse/cuse.3
@@ -136,6 +136,7 @@ Else this function returns zero.
 .Fn "cuse_vmfree" "void *"
 This function frees memory allocated by
 .Fn cuse_vmalloc .
+This function is NULL safe.
 Note that the
 cuse library will internally not free the memory until the
 .Fn cuse_uninit
diff --git a/lib/libcuse/cuse_lib.c b/lib/libcuse/cuse_lib.c
index fda0c96d0d70..d241ce1dc4ac 100644
--- a/lib/libcuse/cuse_lib.c
+++ b/lib/libcuse/cuse_lib.c
@@ -269,7 +269,7 @@ cuse_vmfree(void *ptr)
        int error;
        int n;
 
-       if (f_cuse < 0)
+       if (f_cuse < 0 || ptr == NULL)
                return;
 
        CUSE_LOCK();

Reply via email to