gpu: host1x: Fix potential double free if IOMMU is disabled
authorYang Yingliang <yangyingliang@huawei.com>
Sat, 26 Nov 2022 07:33:14 +0000 (15:33 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:03:12 +0000 (23:03 +0900)
commitb81cfee96703614eb383348e6d6d751d7c6f689e
tree16aab6e7714f4f570ee7a2419258ab37d3e4bb96
parent62cb9c468dc944ead560692397fbde6dbac1a6f0
gpu: host1x: Fix potential double free if IOMMU is disabled

[ Upstream commit 8466ff24a37a9a18fb935e90dda64f049131ae28 ]

If context device has no IOMMU, the 'cdl->devs' is freed in
error path, but host1x_memory_context_list_init() doesn't
return an error code, so the module can be loaded successfully,
when it's unloading, the host1x_memory_context_list_free() is
called in host1x_remove(), it will cause double free. Set the
'cdl->devs' to NULL after freeing it to avoid double free.

Fixes: 8aa5bcb61612 ("gpu: host1x: Add context device management code")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/host1x/context.c