Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752512AbdLLIsS (ORCPT ); Tue, 12 Dec 2017 03:48:18 -0500 Received: from m12-15.163.com ([220.181.12.15]:47010 "EHLO m12-15.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbdLLIsR (ORCPT ); Tue, 12 Dec 2017 03:48:17 -0500 From: Jia-Ju Bai To: jes@trained-monkey.org, jes@wildopensource.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close Date: Tue, 12 Dec 2017 16:49:52 +0800 Message-Id: <1513068592-23632-1-git-send-email-baijiaju1990@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: D8CowABnosOgly9a+vNFDQ--.2340S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7GF48CFy3Kw4xKFy7uw4fAFb_yoWfJwbE9F 4v9rW7Jr1agrnYyr1UCw4rZ348t3WrWr1fZrySqay5Ar9Iyr93C397Ar17Xrnxuw43GryD uryUXF4rAry2qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUbl1vDUUUUU== X-Originating-IP: [166.111.70.15] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiYwSselaDwGRx3AAAst Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 841 Lines: 31 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 --- 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