c
    // In gpio_chardev_data structure definition
    spinlock_t watched_lines_lock;

    // In gpio_chrdev_release
    spin_lock(&cdev->watched_lines_lock);
    bitmap_free(cdev->watched_lines);
    cdev->watched_lines = NULL;
    spin_unlock(&cdev->watched_lines_lock);

    // Before accessing watched_lines elsewhere in the code
    spin_lock(&cdev->watched_lines_lock);
    if (cdev->watched_lines) {
        // Access watched_lines
    }
    spin_unlock(&cdev->watched_lines_lock);
    