Skip to contentSkip to conversation

vme: Fix a possible sleep-in-atomic bug in vme_tsi148

PATCH New Jia-Ju Bai 1 participant 1 message Dec 12, 2017

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 vme: Fix a possible sleep-in-atomic bug in vme_tsi148

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.

---
 drivers/vme/vme.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vme/vme.c +1 -1
index 8124622..92500f6 100644
@@ -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;
 
Signature · 1 line
1.7.9.5