From 2ca43c3dba1b818db9245027c87fddfc9d4be0a6 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 13 Jul 2022 17:54:24 +0200 Subject: [PATCH] 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 74888a687be..aab8ebb4d4f 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 fda0c96d0d7..d241ce1dc4a 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();