Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1820852imm; Mon, 3 Sep 2018 10:17:06 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY85PiG+ZzdfOQ6KpbDTM139X2SUS35xNnkVotGJv6G1VmZBoT2e0SMDSWhWk97SqzGi7bM X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr29784699plh.52.1535995026466; Mon, 03 Sep 2018 10:17:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535995026; cv=none; d=google.com; s=arc-20160816; b=sx/v/VnhiinYlL/qbyN7cLYC0PHDaATyS2hBgind7iV8QxpKQqZjhMMmCDoM7MFYaa BIlVpt4EkS765ABH1dvRdV3qHMmxhoaViUEsGEMCUUCsBQWZ9iZehvQlgot0btjznLm+ 8RmsJkgmhox70VH23E22gWqm56eKyMHI6VUzlCq9cxtglGbT40M7NY0pwLJHYwCIhA/7 EQbY1wPbViH3nzFF9Ad28Z3VIsuUtgZ/i1OI8Zshdfn2JQK8595r4km8Q6sAmbfYC8sT smTvqybCfTfW3T90qZMygdPxY747BbZ2IgZDA6K9h81V86RMKR09vCshyWNoB96g7oSm mQpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=10gzbxrRMAK70mPyz7v9LlXPPsIJBeOW5Yh2lUnbO/U=; b=YSDgRdQjfBa+l3Uyax57GdpobQypvoI32m3Gi0/1cGL7kgYfbK16BS5yvAhN3caEEZ XnIs5ds2jz/oqYdldc2ImhIqzuKu/ErfFerGgBU8tp8kHjpqthXG8sqmoWy04W0hKp+P +LCkin7goWgYwhT2pNRvhly1LeVa5fvaA38rv7DCGgxodcQpSI+n6vRnktD6rttfp/sQ 68OCFL25aPCRUhFbxdxYZNcg/FQOup+4jf5mGNlwsAeW6W2JjX9meBFQ0qTrNaScLJYa A4ciwzZwsOQPamJ38wI27TcCT9C7+Rk+9pOAAgHLto9iTtD4pjwDutzuOX71TuVdF8Uq tKlA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r18-v6si13824220pgb.578.2018.09.03.10.16.51; Mon, 03 Sep 2018 10:17:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729750AbeICVgx (ORCPT + 99 others); Mon, 3 Sep 2018 17:36:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:42448 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727811AbeICVgx (ORCPT ); Mon, 3 Sep 2018 17:36:53 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B1B98D02; Mon, 3 Sep 2018 17:15:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 016/165] usb: gadget: r8a66597: Fix two possible sleep-in-atomic-context bugs in init_controller() Date: Mon, 3 Sep 2018 18:55:02 +0200 Message-Id: <20180903165655.837225607@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165655.003605184@linuxfoundation.org> References: <20180903165655.003605184@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jia-Ju Bai [ Upstream commit 0602088b10a7c0b4e044a810678ef93d7cc5bf48 ] 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 Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/r8a66597-udc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -835,11 +835,11 @@ static void init_controller(struct r8a66 r8a66597_bset(r8a66597, XCKE, SYSCFG0); - msleep(3); + mdelay(3); r8a66597_bset(r8a66597, PLLC, SYSCFG0); - msleep(1); + mdelay(1); r8a66597_bset(r8a66597, SCKE, SYSCFG0);