From 549b39a9e7ef3eee2d0895530f277c012abc7b43 Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Tue, 20 Oct 2015 00:39:01 -0700 Subject: [PATCH] pstore: add vmalloc error check If vmalloc fails, make write_pmsg return -ENOMEM. Signed-off-by: Geliang Tang Acked-by: Kees Cook Signed-off-by: Tony Luck --- fs/pstore/pmsg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c index feb5dd2948b4..5a2f05a16c1e 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; ) { -- 2.20.1