2017-12-12 08:48:18

by Jia-Ju Bai

[permalink] [raw]
Subject: [PATCH] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close

The driver may sleep under a spinlock.
The function call path is:
rr_close (acquire the spinlock)
free_irq --> may sleep

To fix it, free_irq is moved to the place without holding the spinlock.

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

Signed-off-by: Jia-Ju Bai <[email protected]>
---
drivers/net/hippi/rrunner.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index 8483f03..1ab97d9 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1379,8 +1379,8 @@ static int rr_close(struct net_device *dev)
rrpriv->info_dma);
rrpriv->info = NULL;

- free_irq(pdev->irq, dev);
spin_unlock_irqrestore(&rrpriv->lock, flags);
+ free_irq(pdev->irq, dev);

return 0;
}
--
1.7.9.5



2017-12-13 19:53:23

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close

From: Jia-Ju Bai <[email protected]>
Date: Tue, 12 Dec 2017 16:49:52 +0800

> The driver may sleep under a spinlock.
> The function call path is:
> rr_close (acquire the spinlock)
> free_irq --> may sleep
>
> To fix it, free_irq is moved to the place without holding the spinlock.
>
> This bug is found by my static analysis tool(DSAC) and checked by my code review.
>
> Signed-off-by: Jia-Ju Bai <[email protected]>

Applied.