mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: comedi: add error handling for vmap
@ 2018-06-12  3:25 Zhouyang Jia
  2018-06-12 11:50 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Zhouyang Jia @ 2018-06-12  3:25 UTC (permalink / raw)
  Cc: Zhouyang Jia, Ian Abbott, H Hartley Sweeten, Greg Kroah-Hartman,
	Amitoj Kaur Chawla, devel, linux-kernel

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


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

end of thread, other threads:[~2018-06-14  9:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12  3:25 [PATCH] staging: comedi: add error handling for vmap Zhouyang Jia
2018-06-12 11:50 ` Dan Carpenter
     [not found]   ` <CABb2TxKVnC3KkCAs501ffzomOF8GLfLqDvWW=z7mHRf8UKc9YQ@mail.gmail.com>
2018-06-14  9:58     ` Ian Abbott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®