* [PATCH] cgroup: fix possible memory leak
@ 2008-07-28 2:20 Li Zefan
2008-07-30 8:16 ` Paul Menage
[not found] ` <488D2D08.2090903-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
0 siblings, 2 replies; 4+ messages in thread
From: Li Zefan @ 2008-07-28 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Paul Menage, LKML, Linux Containers
There's a leak if copy_from_user() returns failure.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/cgroup.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 657f8f8..28debe4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1424,14 +1424,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
if (buffer == NULL)
return -ENOMEM;
}
- if (nbytes && copy_from_user(buffer, userbuf, nbytes))
- return -EFAULT;
+ if (nbytes && copy_from_user(buffer, userbuf, nbytes)) {
+ retval = -EFAULT;
+ goto out;
+ }
buffer[nbytes] = 0; /* nul-terminate */
strstrip(buffer);
retval = cft->write_string(cgrp, cft, buffer);
if (!retval)
retval = nbytes;
+out:
if (buffer != local_buffer)
kfree(buffer);
return retval;
--
1.5.4.rc3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] cgroup: fix possible memory leak
@ 2008-07-28 2:20 Li Zefan
0 siblings, 0 replies; 4+ messages in thread
From: Li Zefan @ 2008-07-28 2:20 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Containers, Paul Menage, LKML
There's a leak if copy_from_user() returns failure.
Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
kernel/cgroup.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 657f8f8..28debe4 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1424,14 +1424,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
if (buffer == NULL)
return -ENOMEM;
}
- if (nbytes && copy_from_user(buffer, userbuf, nbytes))
- return -EFAULT;
+ if (nbytes && copy_from_user(buffer, userbuf, nbytes)) {
+ retval = -EFAULT;
+ goto out;
+ }
buffer[nbytes] = 0; /* nul-terminate */
strstrip(buffer);
retval = cft->write_string(cgrp, cft, buffer);
if (!retval)
retval = nbytes;
+out:
if (buffer != local_buffer)
kfree(buffer);
return retval;
--
1.5.4.rc3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: fix possible memory leak
[not found] ` <488D2D08.2090903-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
@ 2008-07-30 8:16 ` Paul Menage
0 siblings, 0 replies; 4+ messages in thread
From: Paul Menage @ 2008-07-30 8:16 UTC (permalink / raw)
To: Li Zefan; +Cc: Linux Containers, Andrew Morton, LKML
On Sun, Jul 27, 2008 at 7:20 PM, Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> wrote:
> There's a leak if copy_from_user() returns failure.
>
> Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
Acked-by: Paul Menage <menage-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Thanks, good catch.
> ---
> kernel/cgroup.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 657f8f8..28debe4 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1424,14 +1424,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
> if (buffer == NULL)
> return -ENOMEM;
> }
> - if (nbytes && copy_from_user(buffer, userbuf, nbytes))
> - return -EFAULT;
> + if (nbytes && copy_from_user(buffer, userbuf, nbytes)) {
> + retval = -EFAULT;
> + goto out;
> + }
>
> buffer[nbytes] = 0; /* nul-terminate */
> strstrip(buffer);
> retval = cft->write_string(cgrp, cft, buffer);
> if (!retval)
> retval = nbytes;
> +out:
> if (buffer != local_buffer)
> kfree(buffer);
> return retval;
> --
> 1.5.4.rc3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cgroup: fix possible memory leak
2008-07-28 2:20 [PATCH] cgroup: fix possible memory leak Li Zefan
@ 2008-07-30 8:16 ` Paul Menage
[not found] ` <488D2D08.2090903-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
1 sibling, 0 replies; 4+ messages in thread
From: Paul Menage @ 2008-07-30 8:16 UTC (permalink / raw)
To: Li Zefan; +Cc: Andrew Morton, LKML, Linux Containers
On Sun, Jul 27, 2008 at 7:20 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
> There's a leak if copy_from_user() returns failure.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Paul Menage <menage@google.com>
Thanks, good catch.
> ---
> kernel/cgroup.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup.c b/kernel/cgroup.c
> index 657f8f8..28debe4 100644
> --- a/kernel/cgroup.c
> +++ b/kernel/cgroup.c
> @@ -1424,14 +1424,17 @@ static ssize_t cgroup_write_string(struct cgroup *cgrp, struct cftype *cft,
> if (buffer == NULL)
> return -ENOMEM;
> }
> - if (nbytes && copy_from_user(buffer, userbuf, nbytes))
> - return -EFAULT;
> + if (nbytes && copy_from_user(buffer, userbuf, nbytes)) {
> + retval = -EFAULT;
> + goto out;
> + }
>
> buffer[nbytes] = 0; /* nul-terminate */
> strstrip(buffer);
> retval = cft->write_string(cgrp, cft, buffer);
> if (!retval)
> retval = nbytes;
> +out:
> if (buffer != local_buffer)
> kfree(buffer);
> return retval;
> --
> 1.5.4.rc3
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-07-30 8:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-28 2:20 [PATCH] cgroup: fix possible memory leak Li Zefan
2008-07-30 8:16 ` Paul Menage
[not found] ` <488D2D08.2090903-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-07-30 8:16 ` Paul Menage
-- strict thread matches above, loose matches on Subject: below --
2008-07-28 2:20 Li Zefan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.