From ae02f1e194c562de169659c98cae651c209c5eb4 Mon Sep 17 00:00:00 2001 From: GeLiXin Date: Fri, 19 Aug 2016 14:50:21 +0800 Subject: [PATCH] Fix: handle NULL case in spl_kmem_free_track() When DEBUG_KMEM_TRACKING is enabled in SPL, we keep tracking all the buffers alloced by kmem_alloc() and kmem_zalloc(). If a NULL pointer which indicates no track info in SPL is passed to spl_kmem_free_track, we just ignore it. Signed-off-by: GeLiXin Signed-off-by: Brian Behlendorf Issue zfsonlinux/zfs#4967 Closes #567 --- module/spl/spl-kmem.c | 4 ++++ 1 file changed, 4 insertions(+) mode change 100644 => 100755 module/spl/spl-kmem.c diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c old mode 100644 new mode 100755 index 0931fdfc..2b68c297 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -383,6 +383,10 @@ spl_kmem_free_track(const void *ptr, size_t size) { kmem_debug_t *dptr; + /* Ignore NULL pointer since we haven't tracked it at all*/ + if (ptr == NULL) + return; + /* Must exist in hash due to kmem_alloc() */ dptr = kmem_del_init(&kmem_lock, kmem_table, KMEM_HASH_BITS, ptr); ASSERT3P(dptr, !=, NULL);