From patchwork Sat Sep 1 09:23:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia-Ju Bai X-Patchwork-Id: 10584649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98810920 for ; Sat, 1 Sep 2018 09:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AEE22A40B for ; Sat, 1 Sep 2018 09:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5960F2A72F; Sat, 1 Sep 2018 09:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04B942A40B for ; Sat, 1 Sep 2018 09:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727212AbeIANfP (ORCPT ); Sat, 1 Sep 2018 09:35:15 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33436 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725973AbeIANfP (ORCPT ); Sat, 1 Sep 2018 09:35:15 -0400 Received: by mail-pg1-f196.google.com with SMTP id y3-v6so5282397pgv.0; Sat, 01 Sep 2018 02:23:54 -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=BoKmfDqINy2r744zO3/HpfUNHD/UCUy3WiMQi3DYEuk=; b=VP5xzAL6p0Ooe4WsLWr25Y1tO2QrrHZvoYSZ0P9pWpCnnpa6O0m03Opj3mNLGLffFd w7DScrPVKgEBQatRWzgGFN83wjr3Mq6r2/fQyo9xgnXp3m/JyT/+abjjkgTrAkZEVu6y bCyYbOZFrS/sNnvgnaGklw8JbH3bCCsb/vuZf+uvwwWo0IEF2JVYA7Fm62v3VnWAD+6b MOq/bPcfPFUqX+Oysn4dF8/Xqst2iCxPMJWLcow0avcK8u1ecM5Icu21jhzsc6xjd1MY aOghWPse5iFI87Z0oDqwWtM8YIiR1EPR+4pWKf6WNjyhJe26DjHMl4JiQZY/xmUDS7oL uXaQ== 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=BoKmfDqINy2r744zO3/HpfUNHD/UCUy3WiMQi3DYEuk=; b=hygfOzkBhTTBQQsU5lxDEsbFFh/br8rlUm+XKdkKYbVouJRd+2rY9Ioy+muzQ+MlqU KrgQB7mp8z/VcVPQmio+VOPHiWbRue5HezbP7ZpX1yfzskgb2DSukBNnIXS5GBJA2VA4 pSZhRIIQVdWUna7p0PntuJYlOE61UEPySw6doG67eFiWVI3Jw3neWm+vGG86W0ce17d5 SU7bxXuKQyOJLjbnWIUmDJ0ZmJRu1GnjuSEM5SosYr2cWR5Vc7vMhpo0LrrtCK6w6Nk/ soT3P0y1BdlQnQusWTGFeTMmEqRa2hYKwW245ZinX/aqCH0xYpuFtggrmHXScHeGr8LF vUfw== X-Gm-Message-State: APzg51C4+Ml5PRncjIwNFH9gTaW3m4QbAY8mF4VZDTclF5vB0lMy3kBE p42mO2ewN3pICm+mGJFy6nM= X-Google-Smtp-Source: ANB0VdYq/Vc7ZYgwFGuDFItv6kOrLcY0qq5Ny0et5UW07BEM82jVNe6x4UW6uQcccR4KJqWi1in/6g== X-Received: by 2002:a63:cf52:: with SMTP id b18-v6mr4877558pgj.194.1535793834070; Sat, 01 Sep 2018 02:23:54 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:2913:cd09:aee0:380]) by smtp.gmail.com with ESMTPSA id u184-v6sm18137207pgd.46.2018.09.01.02.23.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Sep 2018 02:23:53 -0700 (PDT) From: Jia-Ju Bai To: gregkh@linuxfoundation.org, johan@kernel.org, felipe.balbi@linux.intel.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] usb: host: u132-hcd: Fix a sleep-in-atomic-context bug in u132_get_frame() Date: Sat, 1 Sep 2018 17:23:47 +0800 Message-Id: <20180901092347.13146-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP i_usX2Y_subs_startup in usbusx2yaudio.c is a completion handler function for the USB driver. So it should not sleep, but it is can sleep according to the function call paths (from bottom to top) in Linux-4.16. [FUNC] msleep drivers/usb/host/u132-hcd.c, 2558: msleep in u132_get_frame drivers/usb/core/hcd.c, 2231: [FUNC_PTR]u132_get_frame in usb_hcd_get_frame_number drivers/usb/core/usb.c, 822: usb_hcd_get_frame_number in usb_get_current_frame_number sound/usb/usx2y/usbusx2yaudio.c, 303: usb_get_current_frame_number in i_usX2Y_urb_complete sound/usb/usx2y/usbusx2yaudio.c, 366: i_usX2Y_urb_complete in i_usX2Y_subs_startup Note that [FUNC_PTR] means a function pointer call is used. To fix this bug, msleep() is replaced with mdelay(). This bug is found by my static analysis tool DSAC. Signed-off-by: Jia-Ju Bai --- drivers/usb/host/u132-hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c index 032b8652910a..02f8e08b3ee8 100644 --- a/drivers/usb/host/u132-hcd.c +++ b/drivers/usb/host/u132-hcd.c @@ -2555,7 +2555,7 @@ static int u132_get_frame(struct usb_hcd *hcd) } else { int frame = 0; dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n"); - msleep(100); + mdelay(100); return frame; } }