Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp445729pxb; Thu, 9 Sep 2021 04:46:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwg8FeFvf1AoVxd/RKhWDmlTQWg5gcNz3E0HdsN1jXIH+SNK8sgr+Cpdiojvj0cCJYFJKLo X-Received: by 2002:a05:6638:2641:: with SMTP id n1mr2385164jat.117.1631188007840; Thu, 09 Sep 2021 04:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188007; cv=none; d=google.com; s=arc-20160816; b=B8E1GEm3PDTgDtc22wgbc9YOwV55Jb3LvmLFxxAkxtmWsKpK0KLPgYCGSv5GteMseC nIOV8pf/zUJunrRw3KN9FfrPJG2xgWN6QmRZ6PIKJYeSPFYMt3Aj0cytyLbCcoQr/+i8 5MVjB94hQVCdeKzyOMM9eturXnSl1U2uXjWxmBRYD+pE3B7J0tDhBnNwXyZHa0oanrQ5 pJ9H48U5gD5CRxTecugSPMlOjuHGS8IeXNWvIzoESgOUtyBNBycqzS1j2zTlcgosuXJN O5//pRr4uuNo0HA80c8EF9nTv+FGRYhA8oURRXd5xJBRbQDl/cTrltOFkBxCitDVG3dv kWtA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0KJqJW9Gznt8MiESPpnFr30YNctWzOiWtSCQvb9kd3Y=; b=MWaZtyP2x8i+1tiA/NHIcmIlf8efO6OjiFNSUvpBTHN5BwoIgIz2dAHIaSS2u5F5cr cFrU0Bbuzt2PEZhgNdjEuYSsTmnBdJEeJqRjEo3OFw1K4orFBN3C9K1pn96LLmA5t894 +mk3T+h3UhTBKiWoLtu+FT+HcBbliyO/VVQ70RrYEtTR1ydQteoYmA4XRMOSEG9itFxm 4GcV1CdRw1UbudXbFYka+MY9VzaYgSN3C1eSrFiAd+/6oR+5qRLeUNZ+84Ytts+cyydz l6HjqnVBbuGhv8TjO9SRaN8GUnaEpdgvvM2VlZJZpTLlUejek+xMMp5Ku5m3S2T1xlXF a34g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ld2j3tFU; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si1298895ioc.55.2021.09.09.04.46.36; Thu, 09 Sep 2021 04:46:47 -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=@kernel.org header.s=k20201202 header.b=Ld2j3tFU; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240509AbhIILp4 (ORCPT + 99 others); Thu, 9 Sep 2021 07:45:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:46772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238935AbhIILnv (ORCPT ); Thu, 9 Sep 2021 07:43:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C105061213; Thu, 9 Sep 2021 11:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187735; bh=cuOdGNw7f1QnFZNVV4eoDeQrIqRmu4KsyB2G/6dTrig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ld2j3tFUkK76VhvILCHgRxtCZRX/C9azLOyPuPCzDIfPw94M+p71Cs8mQgTTUtMpP +5pBuvc7vMR/VsMcqAPsLK/YX6t4I6WPLEbFOppFZ7NOp/q5x/d+A9crbrKc8srPbJ sEpqiniRxbXOhgqPM+07+oQDe90bL3vgnQ21Oiw64g0DZcJ/xh0zYesQCrZs5klowr UpuGWeVtQRlQF9+1rPV7tMc9YT0cheIr8nc3ulrq7fVxjKwpVyOIKdOxl17wZJrexl Tf3alKvWrUheSyxxvPPLNBo/vvYDU946IDDUzCx+MpoqWssfZ+tGSq2FxydtYV9CgK 4UwmfUdfuBbdw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Evgeny Novikov , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.14 054/252] media: platform: stm32: unprepare clocks at handling errors in probe Date: Thu, 9 Sep 2021 07:37:48 -0400 Message-Id: <20210909114106.141462-54-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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