diff
+	atomic_t ref_count;
+	atomic_inc(&thermal_dbg->ref_count);
 	mutex_lock(&thermal_dbg->lock);
 	tz->debugfs = NULL;
 	mutex_unlock(&thermal_dbg->lock);
 	thermal_debugfs_remove_id(thermal_dbg);
+	if (atomic_dec_and_test(&thermal_dbg->ref_count)) {
+		kfree(thermal_dbg);
+	}
