
void thermal_debug_cdev_remove(struct thermal_cooling_device *cdev)
{
-   struct thermal_debugfs *thermal_dbg = cdev->debugfs;
-   
-   if (!thermal_dbg)
+   if (!cdev || !cdev->debugfs)
        return;
+   struct thermal_debugfs *thermal_dbg = cdev->debugfs;
    // ... rest of the function
