Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752495AbdLMKoA (ORCPT ); Wed, 13 Dec 2017 05:44:00 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:37028 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbdLMKn4 (ORCPT ); Wed, 13 Dec 2017 05:43:56 -0500 X-Google-Smtp-Source: ACJfBotoqMVQMhn7VRrrpKeiRH0b3WLghTaiCmEd1XcWg16vBb5Hz9EZzlGTqgg3gHCJiovdD+Y14g== From: Jia-Ju Bai To: nicolas.ferre@microchip.com, rafalo@cadence.com, bfolta@cadence.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] macb: Fix a possible sleep-in-atomic bug in macb_tx_error_task Date: Wed, 13 Dec 2017 18:46:14 +0800 Message-Id: <1513161974-15610-1-git-send-email-baijiaju1990@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 897 Lines: 30 The driver may sleep under a spinlock. The function call path is: macb_tx_error_task (acquire the spinlock) macb_halt_tx usleep_range --> may sleep To fix it, usleep_range is replaced with udelay. This bug is found by my static analysis tool(DSAC) and checked by my code review. Signed-off-by: Jia-Ju Bai --- drivers/net/ethernet/cadence/macb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 72a67f7..b02c806 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -645,7 +645,7 @@ static int macb_halt_tx(struct macb *bp) if (!(status & MACB_BIT(TGO))) return 0; - usleep_range(10, 250); + udelay(250); } while (time_before(halt_time, timeout)); return -ETIMEDOUT; -- 1.7.9.5