c
static bool is_valid_thermal_zone(struct thermal_zone_device *tz)
{
    return tz && tz->debugfs;
}

void thermal_debug_tz_remove(struct thermal_zone_device *tz)
{
    if (!is_valid_thermal_zone(tz))
        return;

    struct thermal_debugfs *thermal_dbg = tz->debugfs;

    mutex_lock(&thermal_dbg->lock);
    // ... rest of the function
}
