vmw_res_type(ctx) == vmw_res_dx_context) {
                for (i = 0; i < cotable_max; ++i) {
                        res = vmw_context_cotable(ctx, i);
-                       if (IS_ERR(res))
+                       if (IS_ERR_OR_NULL(res))
                                continue;
 
                        ret = vmw_execbuf_res_val_add(sw_context, res,
                return -EINVAL;
 
        cotable_res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXQUERY);
+       if (IS_ERR_OR_NULL(cotable_res))
+               return cotable_res ? PTR_ERR(cotable_res) : -EINVAL;
        ret = vmw_cotable_notify(cotable_res, cmd->body.queryId);
 
        return ret;
                return ret;
 
        res = vmw_context_cotable(ctx_node->ctx, vmw_view_cotables[view_type]);
+       if (IS_ERR_OR_NULL(res))
+               return res ? PTR_ERR(res) : -EINVAL;
        ret = vmw_cotable_notify(res, cmd->defined_id);
        if (unlikely(ret != 0))
                return ret;
 
        so_type = vmw_so_cmd_to_type(header->id);
        res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]);
-       if (IS_ERR(res))
-               return PTR_ERR(res);
+       if (IS_ERR_OR_NULL(res))
+               return res ? PTR_ERR(res) : -EINVAL;
        cmd = container_of(header, typeof(*cmd), header);
        ret = vmw_cotable_notify(res, cmd->defined_id);
 
                return -EINVAL;
 
        res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXSHADER);
+       if (IS_ERR_OR_NULL(res))
+               return res ? PTR_ERR(res) : -EINVAL;
        ret = vmw_cotable_notify(res, cmd->body.shaderId);
        if (ret)
                return ret;
        }
 
        res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_STREAMOUTPUT);
+       if (IS_ERR_OR_NULL(res))
+               return res ? PTR_ERR(res) : -EINVAL;
        ret = vmw_cotable_notify(res, cmd->body.soid);
        if (ret)
                return ret;