smalloc: don't crash on being passed a bad pointer
authorJens Axboe <axboe@fb.com>
Tue, 17 Mar 2015 16:45:18 +0000 (10:45 -0600)
committerJens Axboe <axboe@fb.com>
Tue, 17 Mar 2015 16:45:18 +0000 (10:45 -0600)
This can happen if we pass sfree() memory not allocated by smalloc.
Ignore it and log an error instead of triggering an assert().

Signed-off-by: Jens Axboe <axboe@fb.com>
smalloc.c

index b460d6573bbc4e081a394a76808a18e5ee705ab7..447d5c55fe3336986c490c068a5f919a100b55cf 100644 (file)
--- a/smalloc.c
+++ b/smalloc.c
@@ -363,8 +363,12 @@ void sfree(void *ptr)
 
        global_read_unlock();
 
-       assert(pool);
-       sfree_pool(pool, ptr);
+       if (pool) {
+               sfree_pool(pool, ptr);
+               return;
+       }
+
+       log_err("smalloc: ptr %p not from smalloc pool\n", ptr);
 }
 
 static void *__smalloc_pool(struct pool *pool, size_t size)