Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp45021pxb; Mon, 13 Sep 2021 12:29:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmcKRiVd/lxebWy87tXjec4tdL1WLYHeQRotjh3EXbk3ErK383WR4qcZbBmIaSubBrR0Qb X-Received: by 2002:aa7:d490:: with SMTP id b16mr15298874edr.189.1631561371067; Mon, 13 Sep 2021 12:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631561371; cv=none; d=google.com; s=arc-20160816; b=dHOchoG5d/f6VPvB380qp7lKGuOAlENrnK1TbBJRs9Vy3fU/cWoIXxUl0dBPV11Lm6 NvPd3GEHAGuAlk4rdsxht6p/NPwz+7wMy+ceOX3JjlVV8IOhtkTq04Y4ySos/F2djR7s R/ejhtSYjtiVKCau6GeEL6yoLWn0eenB06QeILU2LSvuHcFHoCfGDTUoH4csu6cFpQwg JdDzrMeO52snuIKdrjAVvmfXFcdT2VcSYkNmnJ7gAPSvNZRDd3UPgIeNhZELHeXd72i+ p/E+ujlqp716xavp3CFWvVa2PXSrJ50Dn1E8fTqWrxqyGDKJlNlqVjqpVkWvA3BRIoMW XZnA== 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=DbgPG/ZuynYPbPKzknoU4nzmb8+xFD2uxeXQ0J008XpibBV5XAj1Bn5drFRleazmx5 wU2I77LxHu3VWazYDGhduk6KcuI0QmvcwrhKvV1QMhJPTmZpBn3mZSkJtXiEuA1/vXuT qlWkgEGharANm1vYfkDEGj9XiJBkEXCD1h0jTLK3myP+KTu9/0I9bI57gABkoHBwbw6d usDTsWvP6prLKBWPV406YU1yA8VgedffrrApFZwifjv9izjnbrnaqo7JZuIfG/5AV1ZF Y5eXSXHHF/rLPWKBFUW46/cnwpIttPvkDGkHJSmqZkeWYlUCV31hhtiOojpbVK927xGG QkGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uokiU4wU; 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 jg30si8165260ejc.709.2021.09.13.12.29.06; Mon, 13 Sep 2021 12:29:31 -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=uokiU4wU; 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 S242124AbhIMNd0 (ORCPT + 99 others); Mon, 13 Sep 2021 09:33:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:34832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241301AbhIMNXs (ORCPT ); Mon, 13 Sep 2021 09:23:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BAA7D610D2; Mon, 13 Sep 2021 13:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539288; bh=E080KnkcT6EvMHaaLGSmtuIvM6PZcJ0ayg+8hQXC2Tg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uokiU4wUarkvxPzxJs8GTdpVJl9/YNkjgpjiCB3q3OnYkYnDsjopD0+t1j6vyzYHh 7D5/LjKyMm210Rr97m/+qKMnb5tAiQ3UGTTmJwHwVHQr0YWTZCacw+5vw236u0NWuY vdiaDqRSGiDbOAjkLFzdC8EVpCuUrTodJcNzmDQ4= 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.4 112/144] usb: ehci-orion: Handle errors of clk_prepare_enable() in probe Date: Mon, 13 Sep 2021 15:14:53 +0200 Message-Id: <20210913131051.684777561@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@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