Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp355195imm; Sat, 1 Sep 2018 05:12:30 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda7uxnGnZ9hctA7Hxmi70AwWzrtue2fBB3U2WxSRQpVZZZRMY13pAhU7DwlOm9HCpND3/2J X-Received: by 2002:a62:571b:: with SMTP id l27-v6mr20495773pfb.29.1535803950287; Sat, 01 Sep 2018 05:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535803950; cv=none; d=google.com; s=arc-20160816; b=sHa1/+w7jXfpPRbKEaQ135A1r6CAiGXS2z0o+phUHnpBPvgWj+9lVWTnLa3kZHBRGo fSYoqPZQwhijF5Zvpqu0FO8lV2m4dslGkwa+hbd51loIif9HrfwUAL51AUkVc3Y0qf/7 kmEvZlpSA6JTAezH6woyJ/t8tz5dyvkCVqZR/D3h/FiBoRw9f47/GpHXXrEf8cmLHaSs 3tN5I/8b24ZlrnXvUKPh7n2PssGPw8nPAnZ7q62BiM+L5kXVYUu3ryvONOlEQMM7urAD jYgM2Bz63preJNidea7aiE9SCoToPO4/UuOM0qOE17rHgMvvAD+L3zxLFc5BGwbKr3Fl tGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=urlVOUAThIo2WT+9QwQ1B1RbCWzS5jRVJWYhfhEhD7E=; b=YeG6fPLiSExG98K8BWPfEHYA6YYaJdjTXfnmaJRC62RbnBJxVoM/AsZuQzsO4+lU2l 9dQbkll+C3iTcnkiRKPUATQgbc/r7lh6WiKFE9Gj1mM5shD2t5WUYgCDTSvlaI9pLxew HYLw9FYhYwxigb4dxnzGheWQv3UruMoY0/OOjuzIY2fTIoKaD6yAZSO1R1BBzvHaoSzd VpkBXwiQoT1Kw1dfppw/k8i9ooMP6/keNcxVtPPtiP/J8xoUjdIN2+a17WO+2JBKIsMK eBrCCW9vNx064D/nZhCptZzeQe/QA0cLTgxuzIrZbZPh8Pqyx1mEbybReeo8OxPWwvt5 aD/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aFmGh7VM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p2-v6si12366466pgj.391.2018.09.01.05.12.15; Sat, 01 Sep 2018 05:12:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aFmGh7VM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727421AbeIAQXC (ORCPT + 99 others); Sat, 1 Sep 2018 12:23:02 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44208 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbeIAQXC (ORCPT ); Sat, 1 Sep 2018 12:23:02 -0400 Received: by mail-pf1-f193.google.com with SMTP id k21-v6so6680650pff.11; Sat, 01 Sep 2018 05:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=urlVOUAThIo2WT+9QwQ1B1RbCWzS5jRVJWYhfhEhD7E=; b=aFmGh7VMR4MejHEx/7yh6o2NlPdJ2bTj94iGyVqi3zwoYHq2uOhFZF5NfJdu7d5s10 nBDdJOzR5Dk9+gDR0hVY17odSmOYCHPKczkXxCmIMKAYqeFLWavDru0fICvbAxLNDEgU zmhCvXRmT34zHrXq3F9V17cmatkxFmnNiYmIqhgb3t9/JJeAzy8nwV6ed1V4gh8tk4ig oxPhMWljYPjw4SF2IgsTcpgXaVf6/KvsDuazMz0pwGndR1N7udzjF2U6NOk5IItU1tpX JD5ADq2azJB6w7f8uMXFSZo/0bK+ONFpG9w8/g0GNv0R5b/hDv9pqfNNYTIo9l0wDW+9 nv3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=urlVOUAThIo2WT+9QwQ1B1RbCWzS5jRVJWYhfhEhD7E=; b=cHFa0OYdqd3Wv5Jwn3iYQ0BEKCNvqKSTIrE/svZrYEocvu5adp5PQPB4yv8jzDgGmC p92T0KHyjz9sldli4PHyDHGsNfg4wRlReIQ/L5Me5gzm9cZH9AIrdOHn9wawCFKnsY1f uiw91mSSDFqVUQ7XyGRO1uceIMZW9gH5ONJDATS+IOZ+a7Ifq/wTzPzzM2G+r1aRKsO3 rEjCxvpLVhFq1YGpFUJU3xnIYWhhdv3kR7O5pImlyngaLcDqyiCd15RtmvcrJK5/KBqD ATF8+18EEQR+fidlN2XtOEft8KgvV+DWB7JG2FRmIa7nvb8rc7ND0JYhAbHNF5gJSzzM FqFw== X-Gm-Message-State: APzg51A9wUoEzGluPNmTD9OVzphjVbFuylfaZUExVwhKNCfOzoKI6j7a DSCLPPfmNBnTGU1Apo6zoAI= X-Received: by 2002:a65:450a:: with SMTP id n10-v6mr16569946pgq.392.1535803872086; Sat, 01 Sep 2018 05:11:12 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:2913:cd09:aee0:380]) by smtp.gmail.com with ESMTPSA id y85-v6sm20189389pfa.170.2018.09.01.05.11.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Sep 2018 05:11:11 -0700 (PDT) From: Jia-Ju Bai To: nicolas.ferre@microchip.com, davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx() Date: Sat, 1 Sep 2018 20:11:05 +0800 Message-Id: <20180901121105.436-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel module may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16 are: [FUNC] usleep_range drivers/net/ethernet/cadence/macb_main.c, 648: usleep_range in macb_halt_tx drivers/net/ethernet/cadence/macb_main.c, 730: macb_halt_tx in macb_tx_error_task drivers/net/ethernet/cadence/macb_main.c, 721: _raw_spin_lock_irqsave in macb_tx_error_task To fix this bug, usleep_range() is replaced with udelay(). This bug is found by my static analysis tool DSAC. 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 a6c911bb5ce2..3dcc31cd4261 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -641,7 +641,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; -- 2.17.0