media: venus: hfi: avoid null dereference in deinit
authorLuca Weiss <luca.weiss@fairphone.com>
Fri, 14 Jan 2022 11:02:26 +0000 (11:02 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:33 +0000 (10:22 +0200)
[ Upstream commit 86594f6af867b5165d2ba7b5a71fae3a5961e56c ]

If venus_probe fails at pm_runtime_put_sync the error handling first
calls hfi_destroy and afterwards hfi_core_deinit. As hfi_destroy sets
core->ops to NULL, hfi_core_deinit cannot call the core_deinit function
anymore.

Avoid this null pointer derefence by skipping the call when necessary.

Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/qcom/venus/hfi.c

index 0f2482367e060715d8da7be111605d9927d5c3ac..9bc4becdf63865a6e03b449f3a900fce10471ba9 100644 (file)
@@ -104,6 +104,9 @@ int hfi_core_deinit(struct venus_core *core, bool blocking)
                mutex_lock(&core->lock);
        }
 
+       if (!core->ops)
+               goto unlock;
+
        ret = core->ops->core_deinit(core);
 
        if (!ret)