media: venus: core: handle race condititon for core ops
[sfrench/cifs-2.6.git] / drivers / media / platform / qcom / venus / hfi.c
index a59022adb14c72894aa039981be6ab783f7aa9db..638ed5cfe05e3817dbeb8a99382ce29d5f45a727 100644 (file)
@@ -198,6 +198,18 @@ int hfi_session_init(struct venus_inst *inst, u32 pixfmt)
        const struct hfi_ops *ops = core->ops;
        int ret;
 
+       /*
+        * If core shutdown is in progress or if we are in system
+        * recovery, return an error as during system error recovery
+        * session_init() can't pass successfully
+        */
+       mutex_lock(&core->lock);
+       if (!core->ops || core->sys_error) {
+               mutex_unlock(&core->lock);
+               return -EIO;
+       }
+       mutex_unlock(&core->lock);
+
        if (inst->state != INST_UNINIT)
                return -EINVAL;