Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp68712pxb; Mon, 13 Sep 2021 13:09:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYKKtsxS+TG0IZGPRuvtpccAKmP7FcocotduE+P1BklqMeUGPpoi+EIIp8K84ZoY7vqO80 X-Received: by 2002:a17:906:1856:: with SMTP id w22mr15501543eje.393.1631563793655; Mon, 13 Sep 2021 13:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563793; cv=none; d=google.com; s=arc-20160816; b=ZxkR9Xqri9C50TD5fom/QWZAlD1GiWnPz5Xs4Ye6awLYMMPDGXc3KkcBGWDP3UBvaB OwO8cLVgoG+ZX059Mw/KzjaaVg1H1wT9mCRmmpdGQUgUueZobe6Pz0oYSjbPRq09Xhfl Gu/IRcEW+ccQW5ToQ1TqrQwgsCx0ld+vZVDvfTdWAYj24iF9AOXSx0FIUSTiHCrlfEDR 5YcmwPIDb6UfZbgK7YHQdWaaPYfhwWT0XxexywAxi3yYy8MwBY0x66HXTMuJOiSRWbpM W7YYEUfiSIG7k/2vjEuHT/gIqADdHETvHsoGYsQBT4QEvFNEE6CCZihAODnYC/gYyXiC zizA== 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=U5n31PdYZOB7WUyCiWtNiBji5sxvGrVieQdw4Ivs9Ic=; b=gp4RloMJXCD/tykCT+rxw2Q6cSD6nyvQzokEOQWYwpfvpLaPuVY1GY3eWvl9mcsNtk cGH68wHEhBnrOnpwAgOuJ8B18E9nsOc6wnz6Zq4K6RCEcauDotRBXQHnanGQu8wAxFfp SjLKkBlYZ1OlhW6bOHe7fgOtCml0uSJoF0nbfPVAgihf5V9wznaF6JB470+JHIiydI6Y ixdhAdcur1TBRf0a0TYgiG+AxJ2osQQMilFr0k82o3EAmyWCAoaMdDp4x8aO9PbYxDLN sCeXjErWr0cP7Z1ShJKuO3W6dMFtc5vtHgGOzVIGPjM/MwZGxpLUH4jL+xbGDgGIsLdE lBVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OGb7Ez4j; 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 b10si10205674ejj.523.2021.09.13.13.09.30; Mon, 13 Sep 2021 13:09:53 -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=OGb7Ez4j; 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 S244168AbhIMNtK (ORCPT + 99 others); Mon, 13 Sep 2021 09:49:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:51542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243611AbhIMNok (ORCPT ); Mon, 13 Sep 2021 09:44:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 726F261506; Mon, 13 Sep 2021 13:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539869; bh=E080KnkcT6EvMHaaLGSmtuIvM6PZcJ0ayg+8hQXC2Tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OGb7Ez4j2sdBOyXrK5eJekAqisxjVgc6t6z1bwfIOfNT9mosdq9oHHOTiZoK+SUwX wZ3uVnK/Ey7cbunVYf92dV5FuHhyKP4RfHwRiJybTWayNCHSsH+LA4d0eyZz6/9xRt hYxqHGokx71xrWiY/ffny9PdrNUhAC8t8HS+ob0E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , Alan Stern , Evgeny Novikov , Kirill Shilimanov , Sasha Levin Subject: [PATCH 5.10 193/236] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Date: Mon, 13 Sep 2021 15:14:58 +0200 Message-Id: <20210913131106.948973221@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 4720f1bf4ee4a784d9ece05420ba33c9222a3004 ] 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") Co-developed-by: Kirill Shilimanov Reviewed-by: Andrew Lunn Acked-by: Alan Stern Signed-off-by: Evgeny Novikov Signed-off-by: Kirill Shilimanov Link: https://lore.kernel.org/r/20210825170902.11234-1-novikov@ispras.ru Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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.30.2