Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp743312pxb; Wed, 25 Aug 2021 14:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ2FVsu+ZuqNostqwhkKPaEhAkL1/m//sIzSyOLa8XfzHUgAsYsbLMnDn0uCiNeSvrtQkF X-Received: by 2002:a02:708f:: with SMTP id f137mr374795jac.68.1629925376867; Wed, 25 Aug 2021 14:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629925376; cv=none; d=google.com; s=arc-20160816; b=Qa088bEcgb+bHUxGwHSpcTCLz33KxCT8okjkpv2Gu8uwhIpHxh/1zB+ywfac1Xp1J7 MA/ev7bfSoLzzFUr8by85WwiM/EiD8QdM0uypi31eOYm+5dxYSHCJDj5NVZ63Euf3myx xGrLsjIQQ7fHzQTMa82TsZF+ZAElYNwusOqR+5YS9AAlxyRgrgLW/qKaS236rP9QLL6b lZYacZUI6p/7bdlxfhB7EAsOE0iAZrg3yIJeceQXLNgFKaB8ZkXo8sX5zh4GWyVundvx EPiDh2edSdosCaq68MCGOBpPB0G8AQl3wS19bzJkbbV/A1wpze6hoIo29RGjrNbWzmZp uCaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=qL7y4jydWtI0j/5BDBXG3Kp/lAw61OIAf5fpG8Xo2FE=; b=RR95jTChxNXWIDMeyL6+awYdNbE5Ed2V2SlHAeFAy7g00wUdqYon9UJc1rEc2PTm3t ti12a3nIMP93bRCTVkrevqrxZQH7dlfUzp5PzW7iLBBs6CRCcLU1CrzFAClbMahKW50W K1eV5rXCY2RIglSqsemI0xrnRbXvWjLcm3DTp1c5Z57LWiN95mjf2h/DFqKz9o0Y2K+Y 86c28J+nx2JROCM8qZ/cmW9FYuQ1yYE5CMQ+PgknlqFgx6WCd2mIqYLANNwpGPhUtpJq 6qzm9GMjzcbYAKB0PHIEEzLesTb4mJcJ6OhBet4wHdqhXqQBX4jhgeXFzVAdgm0B6TYf G8Fg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si611656jar.122.2021.08.25.14.02.45; Wed, 25 Aug 2021 14:02:56 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242349AbhHYRaZ (ORCPT + 99 others); Wed, 25 Aug 2021 13:30:25 -0400 Received: from netrider.rowland.org ([192.131.102.5]:48239 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S242307AbhHYRaZ (ORCPT ); Wed, 25 Aug 2021 13:30:25 -0400 Received: (qmail 198861 invoked by uid 1000); 25 Aug 2021 13:29:37 -0400 Date: Wed, 25 Aug 2021 13:29:37 -0400 From: Alan Stern To: Evgeny Novikov Cc: Greg Kroah-Hartman , Andrew Lunn , Mike Turquette , Kirill Shilimanov , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: Re: [PATCH] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Message-ID: <20210825172937.GD192480@rowland.harvard.edu> References: <20210825170902.11234-1-novikov@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210825170902.11234-1-novikov@ispras.ru> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 25, 2021 at 08:09:02PM +0300, Evgeny Novikov wrote: > ehci_orion_drv_probe() did not account for possible errors of > clk_prepare_enable() that in particular could cause invocation of > clk_disable_unprepare() on clocks that were not prepared/enabled yet, > e.g. in remove or on handling errors of usb_add_hcd() in probe. Though, > there were several patches fixing different issues with clocks in this > driver, they did not solve this problem. > > Add handling of errors of clk_prepare_enable() in ehci_orion_drv_probe() > to avoid calls of clk_disable_unprepare() without previous successful > invocation of clk_prepare_enable(). > > Found by Linux Driver Verification project (linuxtesting.org). > > Fixes: 8c869edaee07 ("ARM: Orion: EHCI: Add support for enabling clocks") > Signed-off-by: Evgeny Novikov > Co-developed-by: Kirill Shilimanov > Signed-off-by: Kirill Shilimanov > --- Acked-by: Alan Stern Do you intend to submit patches for the other EHCI drivers that don't check for errors in clk_prepare_enable()? It looks like ehci-atmel.c, ehci-mv.c, and ehci-spear.c all need some attention. The same is true for a bunch of the OHCI drivers: ohci-at91.c, ohci-exynos.c, ohci-s3c2410.c, and ohci-spear.c. Didn't the Linux Driver Verification project identify this problem in all of these drivers? Alan Stern > drivers/usb/host/ehci-orion.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c > index a319b1df3011..3626758b3e2a 100644 > --- a/drivers/usb/host/ehci-orion.c > +++ b/drivers/usb/host/ehci-orion.c > @@ -264,8 +264,11 @@ static int ehci_orion_drv_probe(struct platform_device *pdev) > * the clock does not exists. > */ > priv->clk = devm_clk_get(&pdev->dev, NULL); > - if (!IS_ERR(priv->clk)) > - clk_prepare_enable(priv->clk); > + if (!IS_ERR(priv->clk)) { > + err = clk_prepare_enable(priv->clk); > + if (err) > + goto err_put_hcd; > + } > > priv->phy = devm_phy_optional_get(&pdev->dev, "usb"); > if (IS_ERR(priv->phy)) { > @@ -311,6 +314,7 @@ static int ehci_orion_drv_probe(struct platform_device *pdev) > err_dis_clk: > if (!IS_ERR(priv->clk)) > clk_disable_unprepare(priv->clk); > +err_put_hcd: > usb_put_hcd(hcd); > err: > dev_err(&pdev->dev, "init %s fail, %d\n", > -- > 2.26.2 >