qdev: Fix crash by validating the object type