Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp593770pxb; Wed, 25 Aug 2021 10:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX7Nww91ayGfDQScwSNxbD9AHf0eivATr+udhO8kln4rSx+MzhRGbB4QCyYAz9WpxDI9lb X-Received: by 2002:adf:f7ce:: with SMTP id a14mr17915872wrq.174.1629911534780; Wed, 25 Aug 2021 10:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629911534; cv=none; d=google.com; s=arc-20160816; b=e7Binie0J159DsF8m2FUtvY1uA5t7eefjLKn0A18VylJEb9FywJj0EB5ueOVGIlUyt jMWzHNlE6hklSFuLSXu/EURG0IcHZEpRRj7QN8olrLOZrGmTRoxWlWG8D4Ati3GiNFPY 3qK0/YL1x3nyycGW0Ad3hdxFV2FoxPBTDHwMCtJKz2121Ax6zgMgelfTwnhHjw9TASSw GuECi8xPUaRhS3ju/CqDnD1/ccndBKKLYu4Sko7s2LMmC/K4eAeiFoMLJZxxpO/KJcn7 1rVGS2Qh/1aQ4z8OlSjB0GHXhSxrvVAsOMfZVGeBq0iHdJjT0IW0v+bXHXnlFbyxM5rL mmMQ== 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=5hW/US4ijYqXTwbFcVjJZIYnl+bAk3jEfH9zUBcjJvk=; b=ILXEFowFS5/20uGhvZcUooVZShkireZZjl33rdacsQxlbKdoQ06Q1aOr5Fn6DCeFPE dEbltHPHc7hf1fxBNGIqj8yjBlbwqjt+MUC/JKT6lW0uw0ILr0IKzldNpRNaAoLjjt8u PAY/WkcmRO+xO7DUJxFG9PLSAz57ASY0P09s7koA9PWECmh+eo9HqS/OS/9olbZhgYiP VmM214rNMcGwoSMCUCS9sP2WFCc/wvwujooAnl4Qw3fD+urQmAdCt9oIB4WQ+++db0Pp Xx0g255ovGdidr65eYYbCcgNLHI5yBliNJ5STJNr+XvD8i2+DJwCRwNaZxJ0pRwmdX/5 yu2w== 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 t12si628490edc.179.2021.08.25.10.11.48; Wed, 25 Aug 2021 10:12:14 -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 S242213AbhHYRJ6 (ORCPT + 99 others); Wed, 25 Aug 2021 13:09:58 -0400 Received: from mail.ispras.ru ([83.149.199.84]:54946 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbhHYRJ5 (ORCPT ); Wed, 25 Aug 2021 13:09:57 -0400 Received: from hellwig.intra.ispras.ru (unknown [10.10.2.182]) by mail.ispras.ru (Postfix) with ESMTPS id 93EB240A2BC8; Wed, 25 Aug 2021 17:09:03 +0000 (UTC) From: Evgeny Novikov To: Alan Stern Cc: Evgeny Novikov , Greg Kroah-Hartman , Andrew Lunn , Mike Turquette , Kirill Shilimanov , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Date: Wed, 25 Aug 2021 20:09:02 +0300 Message-Id: <20210825170902.11234-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 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 --- 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