Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp270569imm; Tue, 19 Jun 2018 20:56:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJzg56r4xrqCE66JLigzVG5z/NnG0etk59hpf2N0HpdVaYJ3ZrJ59UCUoMCFehIUfi38TsM X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr21941153plh.291.1529467015064; Tue, 19 Jun 2018 20:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529467015; cv=none; d=google.com; s=arc-20160816; b=xSaLvgBrsmqr53yq6AVlL2iEW0x9Z4c2R3IZnW1i2NCFWHbu3MbS3xh6UkU5yUJUS0 hFxqtzu1clY8bU2jZ2WdL4uKgK0u+rzQidNBO/wki8TvWL4B+e9a7+tlUp/rqbF7JTvn Sm36vgyau0t4e3Vg1FPcJHIlZRCPpvXa4AyDnamqqfXy9T0trMfvZKzrRO0CV/IVVE56 2D0D3ypG8kFJ6Oiyw1zri+qn/vb/L+g4TyVDjPCTL+/8NPqy74BderYKSSDdy3/MZ000 fngYPgw1dEBQKXjPFhSIJsGfA+emLkwpFyEkqvk/Rdx4100grbphtTchxnSs0XQ7jJdS xOUw== 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=EsdU5kluQMf1rXJS2hF6uW+T5S0HXqxcpa9E9XmD+/w=; b=FNcKPT/A+sFXLIRZKxwurlAQpPebwhXpp9ptdI8UlNCXEFsYlZKfvUxlJgdmE0rT1l 3mOQwCO7lzxE8KY0I3o5tU/wNtzjfsDiPCUOQOqjCmPlp+jKDp4wh/iNB/DLToT7a4U0 jxkstEd/NyK06ubdmE+O/HRcWdzGLkzI28EsEg2qGF0MCUKqsjcbuHgAoOM4gkjXjjR5 10poKALC1p7o/mHOlU4pmyn6mjbvilwXTzQNmclNqZNEy81mD2yQ30zm0p4qb4/rv+3K 3s1NHCcaR4/JS+BjVhPaXGOhqP7iyr2kwJAmXAM5HetnBDjVKgrnCmNtKnDGQpfLFJ3w LMFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BvU4AN0z; 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 a4-v6si1315459plp.219.2018.06.19.20.56.26; Tue, 19 Jun 2018 20:56:55 -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=BvU4AN0z; 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 S1754419AbeFTDzM (ORCPT + 99 others); Tue, 19 Jun 2018 23:55:12 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35986 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754331AbeFTDzE (ORCPT ); Tue, 19 Jun 2018 23:55:04 -0400 Received: by mail-pg0-f67.google.com with SMTP id m5-v6so832708pgd.3; Tue, 19 Jun 2018 20:55:04 -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=EsdU5kluQMf1rXJS2hF6uW+T5S0HXqxcpa9E9XmD+/w=; b=BvU4AN0zzyVK7+2xSqpYww5DDMLtCXCaUWh9VaIQ/6VeVUMMkAvuhJkxtYTtM6AXuD hwWXdC9n6k9GooUOjaiTd5LoUvtVnjLrWuAcThlUCY1k/84crl7r8IIXJbWibtr15pgf /FFUvlUaa2tziODQ/p+PadTPjPPz9dlUwHgVZzdd+XsihBeTT26xyugL3tzQKOSIQ0uy 51z1kunFH366j906Ce2sFz4rRzh7VcikBMdpXI4tyeKTzP5O3+f/0UcUVx3WVVGTOJxq Hn8EA1cQ+eqK7jFOW6z86+kyG3yUDh+9XCK/5VlS7IZYqC/VQ81vYGkLbttzUsWQLaMc 8hMw== 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=EsdU5kluQMf1rXJS2hF6uW+T5S0HXqxcpa9E9XmD+/w=; b=pl4XT7QuXUTY8dfndBT8tdyHGUvUhkXFJdJjYM/PQRS0gpIZj77m/Z4Te28D5rcJ+G DfFWtRnOH7wRQidhEqnVUzBbd6AuOTxDukXFgzmqNm/2MQbkGRFtzEsx4fhqRaCo9LHH TYdENGLofa1gIuek94Gf5k67QjyaDFQWfzrslXhfXfeQBjNYdvy3/FlnPlLlFnrmjvmt WdNKNHimcwF6u1c5Hwma079qqJbJuAnxIk5mcYaXfvtwcGP+V2KbqhmUOuhgIna60lDP ZE3DTQIBpRL+xv973C5yJroywJfhjtOaFPg2lX8jOl6hO8XISmHHKsEWBLp14DR+WOTx Kowg== X-Gm-Message-State: APt69E2pYpQN8KFA5Lwmtvc7JzRjCvLnX6+pKGs+9Bt2mPbqiLfBCO2a jvuQkt1QFEpcg1QLFqLMgdc= X-Received: by 2002:a63:6741:: with SMTP id b62-v6mr17379352pgc.5.1529466903990; Tue, 19 Jun 2018 20:55:03 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:d85e:ce7f:5f7a:fdfe]) by smtp.gmail.com with ESMTPSA id 76-v6sm1682059pfr.172.2018.06.19.20.55.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 20:55:03 -0700 (PDT) From: Jia-Ju Bai To: balbi@kernel.org, gregkh@linuxfoundation.org, nicolas.ferre@microchip.com, keescook@chromium.org, robert.jarzmik@free.fr, allen.lkml@gmail.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH 1/2] usb: gadget: r8a66597: Fix two possible sleep-in-atomic-context bugs in init_controller() Date: Wed, 20 Jun 2018 11:54:53 +0800 Message-Id: <20180620035453.7721-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 driver may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16.7 are: [FUNC] msleep drivers/usb/gadget/udc/r8a66597-udc.c, 839: msleep in init_controller drivers/usb/gadget/udc/r8a66597-udc.c, 96: init_controller in r8a66597_usb_disconnect drivers/usb/gadget/udc/r8a66597-udc.c, 93: spin_lock in r8a66597_usb_disconnect [FUNC] msleep drivers/usb/gadget/udc/r8a66597-udc.c, 835: msleep in init_controller drivers/usb/gadget/udc/r8a66597-udc.c, 96: init_controller in r8a66597_usb_disconnect drivers/usb/gadget/udc/r8a66597-udc.c, 93: spin_lock in r8a66597_usb_disconnect To fix these bugs, msleep() is replaced with mdelay(). This bug is found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai --- drivers/usb/gadget/udc/r8a66597-udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index a3ecce62662b..24ee9867964b 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -832,11 +832,11 @@ static void init_controller(struct r8a66597 *r8a66597) r8a66597_bset(r8a66597, XCKE, SYSCFG0); - msleep(3); + mdelay(3); r8a66597_bset(r8a66597, PLLC, SYSCFG0); - msleep(1); + mdelay(1); r8a66597_bset(r8a66597, SCKE, SYSCFG0); -- 2.17.0