]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
vme: Fix a possible sleep-in-atomic bug in vme_tsi148
authorJia-Ju Bai <baijiaju1990@gmail.com>
Tue, 12 Dec 2017 12:51:53 +0000 (20:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 18 Dec 2017 14:59:18 +0000 (15:59 +0100)
The driver may sleep under a spinlock.
The function call path is:
tsi148_master_write \ tsi148_master_read (acquire the spinlock)
  vme_register_error_handler
    kmalloc(GFP_KERNEL) --> may sleep

To fix it, GFP_KERNEL is replaced with GFP_ATOMIC.

This bug is found by my static analysis tool(DSAC) and checked by my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/vme/vme.c

index 81246221a13ba7f2eadd9c8b0455b18bbfca78c1..92500f6bdad194689e43ae630ce7d2147bde2694 100644 (file)
@@ -1290,7 +1290,7 @@ struct vme_error_handler *vme_register_error_handler(
 {
        struct vme_error_handler *handler;
 
-       handler = kmalloc(sizeof(*handler), GFP_KERNEL);
+       handler = kmalloc(sizeof(*handler), GFP_ATOMIC);
        if (!handler)
                return NULL;