tee: amdtee: fix memory leak in amdtee_open_session()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 24 Feb 2020 10:51:39 +0000 (13:51 +0300)
committerJens Wiklander <jens.wiklander@linaro.org>
Thu, 27 Feb 2020 15:22:05 +0000 (16:22 +0100)
commitb83685bceedbeed33a6adc2d0579a011708d2b18
tree871826ba2548317cc4a271fd53d9ef955a5bdf48
parent11a48a5a18c63fd7621bb050228cebf13566e4d8
tee: amdtee: fix memory leak in amdtee_open_session()

On these error paths the "sess" variable isn't freed.  It's a refcounted
pointer so we need to call kref_put().  I re-arranged the code a bit so
the error case is always handled before the success case and the error
paths are indented two tabs.

Fixes: 757cc3e9ff1d ("tee: add AMD-TEE driver")
Reviewed-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
drivers/tee/amdtee/core.c