lkml.org 
[lkml]   [2018]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] staging: comedi: add error handling for vmap
Date
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@gmail.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
\
 
 \ /
  Last update: 2018-06-12 05:26    [W:0.738 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site