pstore: add vmalloc error check
authorGeliang Tang <geliangtang@163.com>
Tue, 20 Oct 2015 07:39:01 +0000 (00:39 -0700)
committerTony Luck <tony.luck@intel.com>
Wed, 21 Oct 2015 16:27:10 +0000 (09:27 -0700)
If vmalloc fails, make write_pmsg return -ENOMEM.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
fs/pstore/pmsg.c

index feb5dd2948b4e4ef7a5857e51389194617f49d76..5a2f05a16c1e3aee45877345f3f998eb9c68a9d3 100644 (file)
@@ -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; ) {