lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180928031226.GB29702@builder>
Date:   Thu, 27 Sep 2018 20:12:26 -0700
From:   Bjorn Andersson <bjorn.andersson@...aro.org>
To:     Colin King <colin.king@...onical.com>
Cc:     Ohad Ben-Cohen <ohad@...ery.com>, linux-remoteproc@...r.kernel.org,
        kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rpmsg: fix memory leak on channel

On Thu 27 Sep 14:36 PDT 2018, Colin King wrote:

> From: Colin Ian King <colin.king@...onical.com>
> 
> Currently a failed allocation of channel->name leads to an
> immediate return without freeing channel. Fix this by setting
> ret to -ENOMEM and jumping to an exit path that kfree's channel.
> 
> Detected by CoverityScan, CID#1473692 ("Resource Leak")
> 
> Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>

Added Cc: stable and applied.

Thanks,
Bjorn

> ---
>  drivers/rpmsg/qcom_smd.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
> index 0dae7c9f4a8f..4abbeea782fa 100644
> --- a/drivers/rpmsg/qcom_smd.c
> +++ b/drivers/rpmsg/qcom_smd.c
> @@ -1122,8 +1122,10 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
>  
>  	channel->edge = edge;
>  	channel->name = kstrdup(name, GFP_KERNEL);
> -	if (!channel->name)
> -		return ERR_PTR(-ENOMEM);
> +	if (!channel->name) {
> +		ret = -ENOMEM;
> +		goto free_channel;
> +	}
>  
>  	spin_lock_init(&channel->tx_lock);
>  	spin_lock_init(&channel->recv_lock);
> @@ -1173,6 +1175,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
>  
>  free_name_and_channel:
>  	kfree(channel->name);
> +free_channel:
>  	kfree(channel);
>  
>  	return ERR_PTR(ret);
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ