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 <ge.lixin@zte.com.cn>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/zfs#4967
Closes #567
This commit is contained in:
GeLiXin 2016-08-19 14:50:21 +08:00 committed by Brian Behlendorf
parent 576865be20
commit aeb9baa618
1 changed files with 4 additions and 0 deletions

4
module/spl/spl-kmem.c Normal file → Executable file
View File

@ -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);