} else if (property == config->prop_crtc_id) {
                struct drm_crtc *crtc = drm_crtc_find(dev, file_priv, val);
+               if (val && !crtc)
+                       return -EACCES;
                return drm_atomic_set_crtc_for_plane(state, crtc);
        } else if (property == config->prop_crtc_x) {
                state->crtc_x = U642I64(val);
 
        if (property == config->prop_crtc_id) {
                struct drm_crtc *crtc = drm_crtc_find(dev, file_priv, val);
+               if (val && !crtc)
+                       return -EACCES;
                return drm_atomic_set_crtc_for_connector(state, crtc);
        } else if (property == config->dpms_property) {
                /* setting DPMS property requires special handling, which