Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2567168lkm; Mon, 20 Sep 2021 18:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypm4Ea7t9tWbOZP45ApUKajD/5MuSBv3CugwGngud4hkKFyq+x4+ba2tkTFEjAXrLh5/qD X-Received: by 2002:a02:9621:: with SMTP id c30mr9917158jai.54.1632188912866; Mon, 20 Sep 2021 18:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188912; cv=none; d=google.com; s=arc-20160816; b=R6jZdC/TtP25UWPcCkC4nPcAn/KTl8zl85p93gPhEvLBUZlPmcu8FIAfjycwFIj2qc z+lbb5RTpxvajlQ50wD9ZZ0p9u+rf2XPoISwnf/Ex+FvygrEF3z4zQ0Md0p9W/O5cTbL EBTGb8LOISLvhkfuJ5stTrZSkezrdhAB3QUw6BxMlNiDc0P0gJSpOMCnChZ56DAH535E kdRY3dxYJtA4DJ0S/R35ECxuqgf9xrlpR+sONMU7yrnSvUsZ9GEQtRtP6x0Wc7kFqo3B G10WymfjufCAAus+7KpAy3e7RS6xsgybI4+h4QSyecRWYnSDaahc/RT/PGf0c+mYmCpS GbQA== 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=xGsAct7R/tszQH0vDyXx3ac7/IxW7jVqHYGNi4k3mVs=; b=LkVIwkehKD/sNBIh/JurMmvyC3jcdKG1IYfuD4b7pBpaS/oKaI8OSL0tHqfGPeY5mn iTV51wswFMeHt8o8fRbQi5mr5poBcio/239l0XIlBJB+OxVJETks7gH8PcCD0/EX/oFJ dk/lS0P84fi4D8pHgaTHEVHa5IcZ5NxVXmQJTT0nibuY2s3UHZ11gI1OxGJf7BiiD+Ad vbgoFuXlcnpgAlNKBXLEUu8LNVf3FZFwGZ9fRmsdzeYBqyQ5X6S5vSw8LHN8J5gCPw64 41znAjpursflQ92Y82c2dp1kEK5HqUWmK3ihxVkASlATQAUG65BdtIhXnBlfd2sno2Wy jjXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A0VOte0j; 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 h15si14923192ili.51.2021.09.20.18.48.21; Mon, 20 Sep 2021 18:48:32 -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=A0VOte0j; 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 S1347018AbhITRmP (ORCPT + 99 others); Mon, 20 Sep 2021 13:42:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:42622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352426AbhITRjZ (ORCPT ); Mon, 20 Sep 2021 13:39:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 96BC461B47; Mon, 20 Sep 2021 17:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632157668; bh=/EGVjqjkW2ksLqUu86HsbHEeo55q7PD/vjBexqhu/68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A0VOte0jcgwUdxoTwjwdcMT+/+M7h1PxHTfJeneeinM7JYHQmi08MoRPeeF/BBAAJ e7xNLaGoIoQAia7ZX7TGcfdzQ4ZoggvbyWclXRmZVNCHdn32MpX6ag1aD3w4lqyBvL uAdHijfb+u27/x97tlU9PaixL7sxiwPgTvoKJmMc= 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 4.19 096/293] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Date: Mon, 20 Sep 2021 18:40:58 +0200 Message-Id: <20210920163936.549910445@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163933.258815435@linuxfoundation.org> References: <20210920163933.258815435@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 1ad72647a069..da0f36af0b38 100644 --- a/drivers/usb/host/ehci-orion.c +++ b/drivers/usb/host/ehci-orion.c @@ -250,8 +250,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)) { @@ -312,6 +315,7 @@ err_phy_init: err_phy_get: 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