Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2319291pxb; Mon, 20 Sep 2021 18:42:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmjUQMSbeMBkMn1S4eH+GT1IaGFi7JvTLpOeu7rFmmYUFBRGtsxyEamprPchUjfFe3IH3m X-Received: by 2002:a92:1306:: with SMTP id 6mr18671897ilt.183.1632188538437; Mon, 20 Sep 2021 18:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188538; cv=none; d=google.com; s=arc-20160816; b=dodW9sbnXY4kXAlrc8BSfu4up8hldbgHTgpGRx2rWOQHeK7raqyUwCAgAacrt6giEG 5rpszbPiMb9NUHMfTa5L6afjHrh4qYdvidZkbXEXMPAECj7hNKNd2r6xBYWqgpmupt/0 7M4JcObuucDDj8VjAsiQJnSZl19DniLZYKqv/oqXwFB4OtFGq93gD7bSqzyK711JljRr tefPcFa3Qm5y2vvZ54KHKQYXQD5tYmzlTHrdI/wnJHOH1Tazoz4yEKBjzi1yVmqAiZGO gfSRkjLRw/7kSWHPJ+Rbzbm2f3qKOI8KEIMur3mnb+c+ah9cILQaAsxB/HXWNhCw5asn eM9A== 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=EclozKGppxKsE4qoX0//9Edt3qcgyvnEoMLgcK8EL7Q=; b=NhVKnGuq5QtoRWIIx73+RTyjsAsj7rQzQRccF5rsluPPHvaE3B48LHTVhfStFSIyRJ 2yddaIxKDBCnL6Nc94nIFsX2LHUnbRmd5a9Owd4c3xb6CAP4pqvtlbWQZ4/lPPJIIgpT foqlve1PrZISK/uxkgxECgJ/S4Gv0yvcL3Q38ZRV8QKdrc8ojQULz7t1ymTyfOQM/0b5 oN9l952O17mjoICCtGGaDYnPZ568JWK2EEI49sCpHRXET0APq2Lhwfi+3JHv7F1O/3Si WE1VVNqKy7qBPz6YOcs0ha3JsxuNq8Mu1nyszUASm/P21uOsGyh0mOtgBNz4c4xH2J6Y zweA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VKYNoSTv; 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 l20si575723jad.72.2021.09.20.18.42.07; Mon, 20 Sep 2021 18:42: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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VKYNoSTv; 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 S245331AbhITQww (ORCPT + 99 others); Mon, 20 Sep 2021 12:52:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:36476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243742AbhITQuE (ORCPT ); Mon, 20 Sep 2021 12:50:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F23BA6124C; Mon, 20 Sep 2021 16:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156517; bh=e3yvkwGqp2Vy9cKkHKiS14Ci8X3/ufrLWKBheCxYQeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VKYNoSTvN02wtOzs4Rf730dQ1064pUjEjkaC62cARXdsnylaqZR/rpMi7Cy7wZzIf O2JG4fy4qfYGzM2hxpaXl78tFvd73IDN2d5nRfPAq5NMFECYk1KylhpTUjPtAxfPmP CxTbem2awku68gFXJRppIf1QYsS+hMpZJpp02wbI= 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.4 064/133] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Date: Mon, 20 Sep 2021 18:42:22 +0200 Message-Id: <20210920163914.744392555@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 ee8d5faa0194..3eecf47d4e89 100644 --- a/drivers/usb/host/ehci-orion.c +++ b/drivers/usb/host/ehci-orion.c @@ -218,8 +218,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)) { @@ -280,6 +283,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