[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1528773937-38106-1-git-send-email-jiazhouyang09@gmail.com>
Date: Tue, 12 Jun 2018 11:25:35 +0800
From: Zhouyang Jia <jiazhouyang09@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@...il.com>,
Ian Abbott <abbotti@....co.uk>,
H Hartley Sweeten <hsweeten@...ionengravers.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Amitoj Kaur Chawla <amitoj1606@...il.com>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org
Subject: [PATCH] staging: comedi: add error handling for vmap
When vmap fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling vmap.
Signed-off-by: Zhouyang Jia <jiazhouyang09@...il.com>
---
drivers/staging/comedi/comedi_buf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c
index f693c2c..5e48693 100644
--- a/drivers/staging/comedi/comedi_buf.c
+++ b/drivers/staging/comedi/comedi_buf.c
@@ -132,9 +132,12 @@ static void __comedi_buf_alloc(struct comedi_device *dev,
spin_unlock_irqrestore(&s->spin_lock, flags);
/* vmap the prealloc_buf if all the pages were allocated */
- if (i == n_pages)
+ if (i == n_pages) {
async->prealloc_buf = vmap(pages, n_pages, VM_MAP,
COMEDI_PAGE_PROTECTION);
+ if (!async->prealloc_buf)
+ dev_err(dev->class_dev, "failed to vmap pages\n");
+ }
vfree(pages);
}
--
2.7.4
Powered by blists - more mailing lists