Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp445731pxb; Thu, 9 Sep 2021 04:46:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRYgd3n1viHxmudomBrcBpdcAEQUllYeflIuNKGv6kIP8PnEEGePFxOOfEnmrIqwqHpzB/ X-Received: by 2002:a05:6e02:d43:: with SMTP id h3mr2003424ilj.112.1631188007848; Thu, 09 Sep 2021 04:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188007; cv=none; d=google.com; s=arc-20160816; b=dSAz0+eJqeL66pY07jgmc1IbIChLLp9ZaHRKQmnXVknOv4IfanrRUEkSZjj/ohq1Kk TnptKiH5C4gG6SHTACp6yn1hnR20hCxRKwtfyaZ3cjP41j1ZnL6AS3sDnju6/DHJq9g9 Zf143UBCpDQ92ohNQVttPRWmwog/w0D9QV10LZwWOSo9QJuRPSi9Vi3y4T/5ueacx5DQ DI2lGE6umltto/mZIgwIafwdK3YBgungFTiCFawgGO3nevN03zAcfoEWMKuWEZwwDxH4 EykdI7Q3QGE4Z5ZgmOzX/I82qHZigH9DjBVmd15OnPKMAye9v548dnbJl8VVH0An0/E+ Jewg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HpQ+kU0W2KarfvDJtT+wKq6fkmZy+1RcPClGT4m2amY=; b=o0JCSLOt68HusOtsr/0vXelPPphxIp4z3lwSPBZX75yxGfQgPNOSbhl633uNaIIGoi gFSQWBKbdPEEEvfY+FkxNQRftNuM1xU6/xLoO5UkMEKXOPczEqvjU3X/XbenDPdLzZjd 45GujjG9DjZPpY6oP7346SlU7dMKv4jrfqzQwNb1vST6nEN7GQbv/in7i6Lj8bMpzarh XnKl/hcSvmJvEYX1l0dPcwUkl/rG34k8A8d7dlF+zCojgLP1Xm7VPoGkEDAhRK0AHQnj /J2s4J7CX8VnsFuOM7irCtQtq2opcStJ7TQL3F71nPup0Oi91jodTg8KbEGfGvbbmiuf b7eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ESQSC5/A"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d39si1404785jaa.115.2021.09.09.04.46.36; Thu, 09 Sep 2021 04:46:47 -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=@kernel.org header.s=k20201202 header.b="ESQSC5/A"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237282AbhIILrB (ORCPT + 99 others); Thu, 9 Sep 2021 07:47:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:45620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237868AbhIILnV (ORCPT ); Thu, 9 Sep 2021 07:43:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3FCCF611C7; Thu, 9 Sep 2021 11:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187721; bh=wb0vY1I/LJsIEVsnaF93j3dbSb5rsRNBhEY+WdFPy2M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ESQSC5/ATcxr9xKZRgwjqpQ3w/qnKQHEQINr683mjO1sc73jkPL7iTma5LS7g5/2/ ZE91hNsgx58ig2kndVZFiFQRnKZWTEM4n7D6pNQvn2wQ2pTo7SCXtZS7UOKCIib3BS RfAQJkSzYy602TeJfxJ2Jm1eYoTwvXO/CRi78k+f38SZ38cJwMchXzs/Utc16yb8lf sVQVht62Ga7u0IWzCtlsMLLAd/ZPUWwg5x0xZLUgtiAWdzjR5LXyw0Z4nfHVjaTVNy 9ERWhTH9cp09ikXYnF+rzNs9SokU8T8Z/QlxVjCgMLLttGdSmqe9PoY4/EeuA4Oc3A rUtz2h77/zM4A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evgeny Novikov , Alan Stern , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 042/252] USB: EHCI: ehci-mv: improve error handling in mv_ehci_enable() Date: Thu, 9 Sep 2021 07:37:36 -0400 Message-Id: <20210909114106.141462-42-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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