Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1700206pxb; Thu, 16 Sep 2021 13:20:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9v398aCHXT+hDm317pRNaSHS17IySMFQyX5vvACiHNthlgr3m/e1f17b3QbEi2ErrDvl0 X-Received: by 2002:a17:906:718e:: with SMTP id h14mr7795866ejk.365.1631823612035; Thu, 16 Sep 2021 13:20:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823612; cv=none; d=google.com; s=arc-20160816; b=0+c2VJf+GnYy8ewGBtxjGiH/Txwn53Lv0Srl/4dk3Yl7spAzapFYJyEzTEm2mh09ol ulKjUQlBcdOsrSuPkrvzbJ9dI84brUYB1OTTuUZ/DKu7Mo1qIC1dpgJ/pNPOPSgs01wv 4fr3b9GmQb4cYxEIZ/NfzghXakZNGNBoA+2v2fGj5VqrsoYk1S/Bp3p4FWtWAGVdO5Vd vzqDyMsSvDfXW3KhoVHDAw4zjWv9uZPqFmxv7wHzVQVMvmqg52kgy5VXHfMWVOqJPwQY vGo6yEHXKuCkKcjJOd/aVJdoNGWKJFa1MRkfEfCeMQXBo1hd29RDxYcX2v/PJWQXqioW qOwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HpQ+kU0W2KarfvDJtT+wKq6fkmZy+1RcPClGT4m2amY=; b=R4L9Honbm+5IZc9JtvstIAZuBfwBMQdVuA/DEWuqPB2eWJoy2WpkuAy8pwDVadp/HF oEN2FCYs96w9c8aPYYYUkM2vUxDeZj35WlyyfbUKZtkXT6qI1kLAw5hlZiTPQpoILWXQ kQ88oO4N1G259X7VDXDWhGgIntQgljsZXfmvMk53mT97phUtlVFxqnnAbMOGclAIxSlI 9fohmifvVJ0160S4iFknuno16bd1wX3GECLruA4grhtznw/RlLzcKNp2wQ6qnmm9KYEE /x5ObE78qRjGfP+k6leGhXNY4UHfsuxwmll9NeOg3zIp1zcg8LdrR6IGPljIY5qeQYrz di2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eQwU+kyq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si4319632eds.602.2021.09.16.13.19.48; Thu, 16 Sep 2021 13:20:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eQwU+kyq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241075AbhIPQVN (ORCPT + 99 others); Thu, 16 Sep 2021 12:21:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236512AbhIPQMO (ORCPT ); Thu, 16 Sep 2021 12:12:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 521176135D; Thu, 16 Sep 2021 16:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808559; bh=wb0vY1I/LJsIEVsnaF93j3dbSb5rsRNBhEY+WdFPy2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQwU+kyqwaf7f8YdzCIgHGq06HaIwAFzt/ft0191sGC37Lv2he26N6zYDXFi7nYil uI5szW2+nOk+axZvw5ShOVaEl/eAiJnh3pgvqeZuPx/bteml7F4YMgF2qKelq/RVC5 6bXZSs9WK6w62TMKIZ4a36Ed0fRkBhNE8cCNE6Is= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Evgeny Novikov , Sasha Levin Subject: [PATCH 5.10 135/306] USB: EHCI: ehci-mv: improve error handling in mv_ehci_enable() Date: Thu, 16 Sep 2021 17:58:00 +0200 Message-Id: <20210916155758.648561205@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Evgeny Novikov [ Upstream commit 61136a12cbed234374ec6f588af57c580b20b772 ] mv_ehci_enable() did not disable and unprepare clocks in case of failures of phy_init(). Besides, it did not take into account failures of ehci_clock_enable() (in effect, failures of clk_prepare_enable()). The patch fixes both issues and gets rid of redundant wrappers around clk_prepare_enable() and clk_disable_unprepare() to simplify this a bit. Found by Linux Driver Verification project (linuxtesting.org). Acked-by: Alan Stern Signed-off-by: Evgeny Novikov Link: https://lore.kernel.org/r/20210708083056.21543-1-novikov@ispras.ru Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/ehci-mv.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/ehci-mv.c b/drivers/usb/host/ehci-mv.c index cffdc8d01b2a..8fd27249ad25 100644 --- a/drivers/usb/host/ehci-mv.c +++ b/drivers/usb/host/ehci-mv.c @@ -42,26 +42,25 @@ struct ehci_hcd_mv { int (*set_vbus)(unsigned int vbus); }; -static void ehci_clock_enable(struct ehci_hcd_mv *ehci_mv) +static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) { - clk_prepare_enable(ehci_mv->clk); -} + int retval; -static void ehci_clock_disable(struct ehci_hcd_mv *ehci_mv) -{ - clk_disable_unprepare(ehci_mv->clk); -} + retval = clk_prepare_enable(ehci_mv->clk); + if (retval) + return retval; -static int mv_ehci_enable(struct ehci_hcd_mv *ehci_mv) -{ - ehci_clock_enable(ehci_mv); - return phy_init(ehci_mv->phy); + retval = phy_init(ehci_mv->phy); + if (retval) + clk_disable_unprepare(ehci_mv->clk); + + return retval; } static void mv_ehci_disable(struct ehci_hcd_mv *ehci_mv) { phy_exit(ehci_mv->phy); - ehci_clock_disable(ehci_mv); + clk_disable_unprepare(ehci_mv->clk); } static int mv_ehci_reset(struct usb_hcd *hcd) -- 2.30.2