/* Should not happen since we thought this minor was free */
        WARN_ON(video_device[vdev->minor] != NULL);
+       video_device[vdev->minor] = vdev;
        vdev->index = get_index(vdev);
        mutex_unlock(&videodev_lock);
 
 #endif
        /* Part 6: Activate this minor. The char device can now be used. */
        set_bit(V4L2_FL_REGISTERED, &vdev->flags);
-       mutex_lock(&videodev_lock);
-       video_device[vdev->minor] = vdev;
-       mutex_unlock(&videodev_lock);
 
        return 0;
 
        mutex_lock(&videodev_lock);
        if (vdev->cdev)
                cdev_del(vdev->cdev);
+       video_device[vdev->minor] = NULL;
        devnode_clear(vdev);
        mutex_unlock(&videodev_lock);
        /* Mark this video device as never having been registered. */