[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <eupntl6hwzg453di3xamztlk5uq32esctulmit56wrbamakcgr@jjyr2rz2x2rp>
Date: Mon, 15 Dec 2025 22:18:46 +0200
From: Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>
To: Haotian Zhang <vulab@...as.ac.cn>
Cc: andersson@...nel.org, konradybcio@...nel.org,
linux-arm-msm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] soc: qcom: cmd-db: Fix memory leak in cmd_db_dev_probe
error path
On Mon, Dec 15, 2025 at 03:41:25PM +0800, Haotian Zhang wrote:
> If cmd_db_magic_matches() fails after memremap() succeeds, the function
> returns -EINVAL without unmapping the memory region, causing a
> potential resource leak.
>
> Add memunmap() call and set cmd_db_header to NULL before returning error
> to properly clean up the mapped memory region.
>
> Fixes: 312416d9171a ("drivers: qcom: add command DB driver")
> Signed-off-by: Haotian Zhang <vulab@...as.ac.cn>
> ---
> drivers/soc/qcom/cmd-db.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Also there is no _remove() function, so the mapped memory will never be
cleaned up. Please consider using devm_memremap() instead.
--
With best wishes
Dmitry
Powered by blists - more mailing lists