Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1701227pxb; Thu, 16 Sep 2021 13:21:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4sPmfc+oD8P/eWNUMfwHj4o3YZgbd7iMRTi4WJWhdMm5GMknknJt4E+0VUFOOL9v8v5RW X-Received: by 2002:a50:eac4:: with SMTP id u4mr8392979edp.259.1631823702168; Thu, 16 Sep 2021 13:21:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631823702; cv=none; d=google.com; s=arc-20160816; b=CFqPfXdAQW9y4/kJ6uDeRn9Gvcz4bOJYPAoGMpHC3KecRON1AAgc6B7PSYvqyYZX1O +Lmkr0DBbnlov6a5MKmYsK8za+hArW9qxk3B5Cdp05r7kqtstPtDejG5FJkZHKnOAg7P c7Djdu8MWcAmFpqze1RCIVncQ1llQIGgZcrAtCzMTrU4W/RocB0G345MHWKoLuzwNW+/ Gl2jI9bL2+r+5EjL6oAA3dgE2rLv3UNhrUXM/FCN6nW37A35J/o1OIiFGMk5fuZRqpkC h5Ratyqi4o/XPOhuHIfGPHonzYFO5chCK9uho6UppXLpUHJMSzsF6UEv+ppeWswE+CyW DJPw== 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=0KJqJW9Gznt8MiESPpnFr30YNctWzOiWtSCQvb9kd3Y=; b=MysvKze/Ct7Di14D+xMjDBVwMhar7uMnlTyiNNSA8VaJCSAGY4LqwCgBY72IlIrIFR 0RCygm4Tvh53uiXlQWWvxute0B+FMLh+jTPlKk+93D2hUYXK8Vs8BK2uvsffwnXTF+yc NWPXjzjem5WXw8KThJiYcPj/SiTf+vYhoOoJa9klvEO7CBq4M/aELOR/p2376GoNOHep Va3LsB8sB2hTeF0lgoFQ+4wj9vwVfcXbRewSNeIcr0m1/P7px410yArrQ2pou4qkprbW XuKNyvyJ0JCpoTGWatk2gnDfQjRKdUJK9ZeCgPMgScEPyDDUrPX5HRKtke15gCCXgTs8 vBig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l0b2XN67; 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 bq19si4154508edb.548.2021.09.16.13.21.16; Thu, 16 Sep 2021 13:21:42 -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=l0b2XN67; 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 S234758AbhIPQYk (ORCPT + 99 others); Thu, 16 Sep 2021 12:24:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:55356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241035AbhIPQPH (ORCPT ); Thu, 16 Sep 2021 12:15:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DFC3F613A8; Thu, 16 Sep 2021 16:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808661; bh=cuOdGNw7f1QnFZNVV4eoDeQrIqRmu4KsyB2G/6dTrig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l0b2XN67qlVBPkvH0WXM2e/GMsE1Td0dXz1p5FnVV3jjDcOoPhsI/ljQ0IEzYxaWw XHILsfIKPjTgdC3kJeUWcMMIIRJY8CXqxxLiU54dVB+VXer4oxkdFzNyUnHtj8NBGG MzunLLV+gCuWP6lVxzegb+qngsoRLgfCY4YX73i4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeny Novikov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 143/306] media: platform: stm32: unprepare clocks at handling errors in probe Date: Thu, 16 Sep 2021 17:58:08 +0200 Message-Id: <20210916155758.926844269@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@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 055d2db28ec2fa3ab5c527c5604f1b32b89fa13a ] stm32_cec_probe() did not unprepare clocks on error handling paths. The patch fixes that. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/platform/stm32/stm32-cec.c | 26 ++++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/media/cec/platform/stm32/stm32-cec.c b/drivers/media/cec/platform/stm32/stm32-cec.c index ea4b1ebfca99..0ffd89712536 100644 --- a/drivers/media/cec/platform/stm32/stm32-cec.c +++ b/drivers/media/cec/platform/stm32/stm32-cec.c @@ -305,14 +305,16 @@ static int stm32_cec_probe(struct platform_device *pdev) cec->clk_hdmi_cec = devm_clk_get(&pdev->dev, "hdmi-cec"); if (IS_ERR(cec->clk_hdmi_cec) && - PTR_ERR(cec->clk_hdmi_cec) == -EPROBE_DEFER) - return -EPROBE_DEFER; + PTR_ERR(cec->clk_hdmi_cec) == -EPROBE_DEFER) { + ret = -EPROBE_DEFER; + goto err_unprepare_cec_clk; + } if (!IS_ERR(cec->clk_hdmi_cec)) { ret = clk_prepare(cec->clk_hdmi_cec); if (ret) { dev_err(&pdev->dev, "Can't prepare hdmi-cec clock\n"); - return ret; + goto err_unprepare_cec_clk; } } @@ -324,19 +326,27 @@ static int stm32_cec_probe(struct platform_device *pdev) CEC_NAME, caps, CEC_MAX_LOG_ADDRS); ret = PTR_ERR_OR_ZERO(cec->adap); if (ret) - return ret; + goto err_unprepare_hdmi_cec_clk; ret = cec_register_adapter(cec->adap, &pdev->dev); - if (ret) { - cec_delete_adapter(cec->adap); - return ret; - } + if (ret) + goto err_delete_adapter; cec_hw_init(cec); platform_set_drvdata(pdev, cec); return 0; + +err_delete_adapter: + cec_delete_adapter(cec->adap); + +err_unprepare_hdmi_cec_clk: + clk_unprepare(cec->clk_hdmi_cec); + +err_unprepare_cec_clk: + clk_unprepare(cec->clk_cec); + return ret; } static int stm32_cec_remove(struct platform_device *pdev) -- 2.30.2