Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1275231 > unrolled thread

[PATCH] lightnvm: fix memory leak

Started bySudip Mukherjee <sudipm.mukherjee@gmail.com>
First post2015-11-23 11:40 +0100
Last post2015-11-23 19:50 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] lightnvm: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-23 11:40 +0100
    Re: [PATCH] lightnvm: fix memory leak Matias Bjørling <mb@lightnvm.io> - 2015-11-23 16:20 +0100
      Re: [PATCH] lightnvm: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-23 17:50 +0100
        Re: [PATCH] lightnvm: fix memory leak Matias <mb@lightnvm.io> - 2015-11-23 19:50 +0100

#1275231 — [PATCH] lightnvm: fix memory leak

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-11-23 11:40 +0100
Subject[PATCH] lightnvm: fix memory leak
Message-ID<qxWHo-x4-13@gated-at.bofh.it>
If copy_to_user() fails we returned error but we missed releasing
devices.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/lightnvm/core.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index f659e60..6688b60 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -721,8 +721,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;
-- 
1.9.1

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

[toc] | [next] | [standalone]


#1275470

FromMatias Bjørling <mb@lightnvm.io>
Date2015-11-23 16:20 +0100
Message-ID<qy14m-3zj-27@gated-at.bofh.it>
In reply to#1275231
On 11/23/2015 11:35 AM, Sudip Mukherjee wrote:
> If copy_to_user() fails we returned error but we missed releasing
> devices.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>   drivers/lightnvm/core.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> index f659e60..6688b60 100644
> --- a/drivers/lightnvm/core.c
> +++ b/drivers/lightnvm/core.c
> @@ -721,8 +721,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, it seems like this error is in some of the others ioctl's 
as well. Do you want to send a patch with the fixes for them all?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1275625

FromSudip Mukherjee <sudipm.mukherjee@gmail.com>
Date2015-11-23 17:50 +0100
Message-ID<qy2ts-4pB-31@gated-at.bofh.it>
In reply to#1275470
On Mon, Nov 23, 2015 at 04:13:39PM +0100, Matias Bjørling wrote:
> On 11/23/2015 11:35 AM, Sudip Mukherjee wrote:
> >If copy_to_user() fails we returned error but we missed releasing
> >devices.
> >
> >Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> >---
> >  drivers/lightnvm/core.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> >diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
> >index f659e60..6688b60 100644
> >--- a/drivers/lightnvm/core.c
> >+++ b/drivers/lightnvm/core.c
> >@@ -721,8 +721,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, it seems like this error is in some of the others
> ioctl's as well. Do you want to send a patch with the fixes for them
> all?

I can find a similar error in nvm_ioctl_info(). I will have a close look
tomorrow and send a patch. Is this patch applied or should I send a
combined patch fixing all these similar errors?

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

[toc] | [prev] | [next] | [standalone]


#1275739

FromMatias <mb@lightnvm.io>
Date2015-11-23 19:50 +0100
Message-ID<qy4lz-5FS-17@gated-at.bofh.it>
In reply to#1275625
On 11/23/2015 05:40 PM, Sudip Mukherjee wrote:
> On Mon, Nov 23, 2015 at 04:13:39PM +0100, Matias Bjørling wrote:
>> On 11/23/2015 11:35 AM, Sudip Mukherjee wrote:
>>> If copy_to_user() fails we returned error but we missed releasing
>>> devices.
>>>
>>> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
>>> ---
>>>   drivers/lightnvm/core.c | 5 ++++-
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
>>> index f659e60..6688b60 100644
>>> --- a/drivers/lightnvm/core.c
>>> +++ b/drivers/lightnvm/core.c
>>> @@ -721,8 +721,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, it seems like this error is in some of the others
>> ioctl's as well. Do you want to send a patch with the fixes for them
>> all?

Sure, That'll be great. Then I'll apply it.

>
> I can find a similar error in nvm_ioctl_info(). I will have a close look
> tomorrow and send a patch. Is this patch applied or should I send a
> combined patch fixing all these similar errors?

A combined will be great. It fixes the same type of error. Thank you.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web