Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp250750pxv; Thu, 8 Jul 2021 01:32:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2vlRsIbhfYS/SePSU+u84dL2iwrHcXZs5MOVoC+yRZkKpoE49VEP1bfvo5Q3M2P6iKkYg X-Received: by 2002:a05:6638:341:: with SMTP id x1mr25518241jap.118.1625733138410; Thu, 08 Jul 2021 01:32:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625733138; cv=none; d=google.com; s=arc-20160816; b=tdTckUXCQsTXU1bLwiY2JtJ5Qz4KwqFxCESBp+OrxtiwxO3YJTTpguKuA36Dgq+uNc Kl+ED4/UfAWtq3gGqmY8iT/ea6Q3xRcTfgeHMdpzBWX6TQ0rCMcrJnibreseXLP75F+3 5Vophq/zCWL4NFhJNK9CsivnyFeG59WBcjfoXjZ/xXcjYsjXYuXjyLnVr2o1/kKgvw6w DZxG9eL1GHDKRW5NPJ0+P34LdeaKgpJsbPe19oy4t8jdEdx/z8pTkxM+TWOafnJrEdcO b8WtNnAh8S0khKRYu4dYBTapXfC34Co2rZB5tZh9CxvWmdd7smQlxyDLwvfdB+oxC1wR 1aUg== 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 :message-id:date:subject:cc:to:from; bh=up2gMfJtIcqLbVFgOEc0ySGwAwrUj8xOmapcabZXlzY=; b=bEVaoBtVQWlmJsb0E2pellDm67zBBT8ljnLIx6Cs0Pr3yobHdaXOMmuU6A5paILDvF e1JzyW5oRn/xSO4DVfiB6WiS0hCF4ks25GW5B6wB/JEO/hWTkpM+xHK8AAxGU2XWdIqL WoGyvMe1Gyew0A+ypSrjOARINBeuY6qsoZp5Txql3bqddJlh2cj4HawY+nLlFAXM8zFK nDRB0iQoW+IcP65B/bfk99iv0V8H84ZZdvh9d1C0vc1ogB3F8jfa4CRVKhux3iHCgomI 18WAGuj9A8nOaIBrpjlvp6YLPmIFmEnYxra5cLHZpbsbj7FKTmuh1rhwwKglCmKT+UP6 w1zw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si2142742ilu.13.2021.07.08.01.32.05; Thu, 08 Jul 2021 01:32:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbhGHIdm (ORCPT + 99 others); Thu, 8 Jul 2021 04:33:42 -0400 Received: from mail.ispras.ru ([83.149.199.84]:54250 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbhGHIdm (ORCPT ); Thu, 8 Jul 2021 04:33:42 -0400 Received: from hellwig.intra.ispras.ru (unknown [83.149.199.249]) by mail.ispras.ru (Postfix) with ESMTPS id 484EF40A2BAA; Thu, 8 Jul 2021 08:30:57 +0000 (UTC) From: Evgeny Novikov To: Alan Stern Cc: Evgeny Novikov , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] USB: EHCI: ehci-mv: improve error handling in mv_ehci_enable() Date: Thu, 8 Jul 2021 11:30:56 +0300 Message-Id: <20210708083056.21543-1-novikov@ispras.ru> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). Signed-off-by: Evgeny Novikov --- 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.26.2