tee: optee: fix device enumeration error handling
authorJens Wiklander <jens.wiklander@linaro.org>
Wed, 6 Nov 2019 15:48:28 +0000 (16:48 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 26 Jan 2020 09:01:07 +0000 (10:01 +0100)
commitb30a9b012a4e9b400a3e3caa0e4c83d77089ef7b
tree3ea22e094bc47f479840e50e2942a58d6c322c3e
parent5c179c003b45909df8bf55c072df897bcb2ef0e0
tee: optee: fix device enumeration error handling

[ Upstream commit 03212e347f9443e524d6383c6806ac08295c1fb0 ]

Prior to this patch in optee_probe() when optee_enumerate_devices() was
called the struct optee was fully initialized. If
optee_enumerate_devices() returns an error optee_probe() is supposed to
clean up and free the struct optee completely, but will at this late
stage need to call optee_remove() instead. This isn't done and thus
freeing the struct optee prematurely.

With this patch the call to optee_enumerate_devices() is done after
optee_probe() has returned successfully and in case
optee_enumerate_devices() fails everything is cleaned up with a call to
optee_remove().

Fixes: c3fa24af9244 ("tee: optee: add TEE bus device enumeration support")
Reviewed-by: Sumit Garg <sumit.garg@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tee/optee/core.c