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] [thread-next>] [day] [month] [year] [list]
Message-ID: <56544293.50007@bjorling.me>
Date:	Tue, 24 Nov 2015 11:57:23 +0100
From:	Matias Bjørling <m@...rling.me>
To:	Sudip Mukherjee <sudipm.mukherjee@...il.com>,
	Matias Bjorling <mb@...htnvm.io>
CC:	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/5] lightnvm: fix memory leak

On 11/24/2015 11:34 AM, Sudip Mukherjee wrote:
> If copy_to_user() fails we returned error but we missed releasing
> devices.
>
> Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>
> ---
>
> v1 on fixed one error. v2 fixes both.
>
>   drivers/lightnvm/core.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index f659e60..e338048 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -677,8 +677,10 @@ static long nvm_ioctl_info(struct file *file, void __user *arg)
>   	info->tgtsize = tgt_iter;
>   	up_write(&nvm_lock);
>
> -	if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info)))
> +	if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) {
> +		kfree(info);
>   		return -EFAULT;
> +	}
>
>   	kfree(info);
>   	return 0;
> @@ -721,8 +723,11 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg)
>
>   	devices->nr_devices = i;
>
> -	if (copy_to_user(arg, devices, sizeof(struct nvm_ioctl_get_devices)))
> +	if (copy_to_user(arg, devices,
> +			 sizeof(struct nvm_ioctl_get_devices))) {
> +		kfree(devices);
>   		return -EFAULT;
> +	}
>
>   	kfree(devices);
>   	return 0;
>
Thanks Sudip, applied.
--
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