linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pstore: add vmalloc error check
@ 2015-10-13  9:27 Geliang Tang
  2015-10-13 20:15 ` Kees Cook
  0 siblings, 1 reply; 2+ messages in thread
From: Geliang Tang @ 2015-10-13  9:27 UTC (permalink / raw)
  To: Anton Vorontsov, Colin Cross, Kees Cook, Tony Luck
  Cc: Geliang Tang, linux-kernel

If vmalloc is failed, return -ENOMEM.

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 fs/pstore/pmsg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
index feb5dd2..5a2f05a 100644
--- a/fs/pstore/pmsg.c
+++ b/fs/pstore/pmsg.c
@@ -37,6 +37,8 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf,
 	if (buffer_size > PMSG_MAX_BOUNCE_BUFFER_SIZE)
 		buffer_size = PMSG_MAX_BOUNCE_BUFFER_SIZE;
 	buffer = vmalloc(buffer_size);
+	if (!buffer)
+		return -ENOMEM;
 
 	mutex_lock(&pmsg_lock);
 	for (i = 0; i < count; ) {
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pstore: add vmalloc error check
  2015-10-13  9:27 [PATCH] pstore: add vmalloc error check Geliang Tang
@ 2015-10-13 20:15 ` Kees Cook
  0 siblings, 0 replies; 2+ messages in thread
From: Kees Cook @ 2015-10-13 20:15 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Anton Vorontsov, Colin Cross, Tony Luck, LKML

On Tue, Oct 13, 2015 at 2:27 AM, Geliang Tang <geliangtang@163.com> wrote:
> If vmalloc is failed, return -ENOMEM.
>
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  fs/pstore/pmsg.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
> index feb5dd2..5a2f05a 100644
> --- a/fs/pstore/pmsg.c
> +++ b/fs/pstore/pmsg.c
> @@ -37,6 +37,8 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf,
>         if (buffer_size > PMSG_MAX_BOUNCE_BUFFER_SIZE)
>                 buffer_size = PMSG_MAX_BOUNCE_BUFFER_SIZE;
>         buffer = vmalloc(buffer_size);
> +       if (!buffer)
> +               return -ENOMEM;
>
>         mutex_lock(&pmsg_lock);
>         for (i = 0; i < count; ) {
> --
> 1.9.1

I thought I saw this fix come through before? Regardless, thank you!

Acked-by: Kees Cook <keescook@chromium.org>

-Kees


-- 
Kees Cook
Chrome OS Security

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-13 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-13  9:27 [PATCH] pstore: add vmalloc error check Geliang Tang
2015-10-13 20:15 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).