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>] [day] [month] [year] [list]
Date:	Wed, 25 Mar 2015 01:11:48 -0500
From:	Larry Finger <Larry.Finger@...inger.net>
To:	Nicholas Krause <xerofoify@...il.com>, rmk+kernel@....linux.org.uk
CC:	dbaryshkov@...il.com, linux-pcmcia@...ts.infradead.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] pcmcia:Fix memory leaks in the function, sa11xx_drv_pcmcia_probe

On 03/24/2015 11:24 PM, Nicholas Krause wrote:
> Fixes memory leaks in the function,sa11xx_drv_pcmcia_probe for
> when either clk_get returns a error value  or when we cannot allocate
> memory  with the pointer sinfo to memory required for this function
> to continue and return successfully. Further more this was caught by
> running coccinelle on the lastet kernel tree.
>
> Signed-off-by: Nicholas Krause <xerofoify@...il.com>
> ---
>   drivers/pcmcia/sa11xx_base.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pcmcia/sa11xx_base.c b/drivers/pcmcia/sa11xx_base.c
> index cf6de2c..a95ce73 100644
> --- a/drivers/pcmcia/sa11xx_base.c
> +++ b/drivers/pcmcia/sa11xx_base.c
> @@ -223,14 +223,19 @@ int sa11xx_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops,
>   	struct clk *clk;
>
>   	clk = clk_get(dev, NULL);
> -	if (IS_ERR(clk))
> +	if (IS_ERR(clk)) {
> +		clk_put(clk);
>   		return PTR_ERR(clk);
> +	}

If the clk_get() failed, then there is no need to use a clk_put(). In addition, 
clk contains an error code, not a valid pointer. This change would crash the 
system every time clk_get() failed.

>
>   	sa11xx_drv_pcmcia_ops(ops);
>
>   	sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
> -	if (!sinfo)
> +	if (!sinfo) {
> +		clk_put(clk);
> +		kfree(sinfo);
>   		return -ENOMEM;

If the memory allocation failed, there is nothing to free. That kfree() call is 
not needed; however, the clk_put() is needed here.

NACK.

Larry


> +	}
>
>   	sinfo->nskt = nr;
>   	sinfo->clk = clk;
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ