tee: optee: Fix incorrect page free bug
authorSumit Garg <sumit.garg@linaro.org>
Thu, 16 Dec 2021 05:47:25 +0000 (11:17 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Dec 2021 11:26:05 +0000 (12:26 +0100)
commitad338d825e3f7b96ee542bf313728af2d19fe9ad
tree5132e250be62f24a1ba858fac69c005cc241dd73
parent1f207076740101fed87074a6bc924dbe806f08a5
tee: optee: Fix incorrect page free bug

commit 18549bf4b21c739a9def39f27dcac53e27286ab5 upstream.

Pointer to the allocated pages (struct page *page) has already
progressed towards the end of allocation. It is incorrect to perform
__free_pages(page, order) using this pointer as we would free any
arbitrary pages. Fix this by stop modifying the page pointer.

Fixes: ec185dd3ab25 ("optee: Fix memory leak when failing to register shm pages")
Cc: stable@vger.kernel.org
Reported-by: Patrik Lantz <patrik.lantz@axis.com>
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tee/optee/shm_pool.c