]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
remoteproc: Fix a memory leak in an error handling path in 'rproc_handle_vdev()'
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sat, 4 Sep 2021 11:37:32 +0000 (13:37 +0200)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:48:33 +0000 (09:48 +0100)
commit1ed5b9cbdff47ffe28b2f66f63776c4d7317199c
tree8b5fcf5d6ab52e2d42fb0870e42518f9b65e0083
parent2c5f258cb111802d3b1309aeaaa3c888500cccdd
remoteproc: Fix a memory leak in an error handling path in 'rproc_handle_vdev()'

BugLink: https://bugs.launchpad.net/bugs/1951822
[ Upstream commit 0374a4ea7269645c46c3eb288526ea072fa19e79 ]

If 'copy_dma_range_map() fails, the memory allocated for 'rvdev' will leak.
Move the 'copy_dma_range_map()' call after the device registration so
that 'rproc_rvdev_release()' can be called to free some resources.

Also, branch to the error handling path if 'copy_dma_range_map()' instead
of a direct return to avoid some other leaks.

Fixes: e0d072782c73 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jim Quinlan <james.quinlan@broadcom.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/e6d0dad6620da4fdf847faa903f79b735d35f262.1630755377.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/remoteproc/remoteproc_core.c