mutex_lock(&core->lock);
 
+       if (test_bit(0, &inst->core->sys_error)) {
+               ret = -EIO;
+               goto unlock;
+       }
+
        max = atomic_add_unless(&core->insts_count, 1,
                                core->max_sessions_supported);
        if (!max) {
                ret = 0;
        }
 
+unlock:
        mutex_unlock(&core->lock);
 
        return ret;
        if (inst->state < INST_INIT)
                return -EINVAL;
 
+       if (test_bit(0, &inst->core->sys_error))
+               goto done;
+
        reinit_completion(&inst->done);
 
        ret = ops->session_end(inst);
        if (ret)
                return ret;
 
+done:
        inst->state = INST_UNINIT;
 
        return 0;
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (inst->state != INST_LOAD_RESOURCES)
                return -EINVAL;
 
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (inst->state != INST_START)
                return -EINVAL;
 
 {
        struct venus_core *core = inst->core;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (core->res->hfi_version == HFI_VERSION_1XX)
                return 0;
 
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        reinit_completion(&inst->done);
 
        ret = ops->session_abort(inst);
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (inst->state != INST_INIT)
                return -EINVAL;
 
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (inst->state != INST_STOP)
                return -EINVAL;
 
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        reinit_completion(&inst->done);
 
        ret = ops->session_flush(inst, type);
 {
        const struct hfi_ops *ops = inst->core->ops;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        return ops->session_set_buffers(inst, bd);
 }
 
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        reinit_completion(&inst->done);
 
        ret = ops->session_unset_buffers(inst, bd);
        const struct hfi_ops *ops = inst->core->ops;
        int ret;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (inst->state < INST_INIT || inst->state >= INST_STOP)
                return -EINVAL;
 
 {
        const struct hfi_ops *ops = inst->core->ops;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (inst->state < INST_INIT || inst->state >= INST_STOP)
                return -EINVAL;
 
 {
        const struct hfi_ops *ops = inst->core->ops;
 
+       if (test_bit(0, &inst->core->sys_error))
+               return -EIO;
+
        if (fd->buffer_type == HFI_BUFFER_INPUT)
                return ops->session_etb(inst, fd);
        else if (fd->buffer_type == HFI_BUFFER_OUTPUT ||