Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1932659pxb; Thu, 16 Sep 2021 20:45:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7+6GZLIqWMCFRd3pDxFRH83nS3Xr/pmOKE1sFxuWduhVd6/o9JwfCnEMSSukEworcUtIR X-Received: by 2002:a05:6e02:198c:: with SMTP id g12mr6261711ilf.77.1631850315072; Thu, 16 Sep 2021 20:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631850315; cv=none; d=google.com; s=arc-20160816; b=epHSAAV1Fo7409w80+lORBgZN7GAwMRHK8N5a0oqA7hDbQaaa0lJfPWKTHb7iMXYz/ kwk+2BYsVZXmlNeS3M0CSZDX2WqtkUf0pyqukWkhHlU7ijME86pnb1TjREIDK2joo5vO TBjX2k9u5+9xZS6uYWl7n/rTJAetivBgKziYE5ZJxS2dxl5xuGzqj4v/+8MJ3m7Ti8V7 2girdxsZogWJ1FAk4OPNV2H+Nz8HIwHZPDm9JEmKrzMSTemtR7CVrQDN2cgP0uzeNRac 0GwTswcUkYagGvj702tmI1WaenMLpTLlkTBWEuAe1/Elfl1FDCbZv0H9jUC9CmzqxdWz F6sg== 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=eqXsKOtDjtfnPwRk5cEXt2KdFafcIFO9dCXGIFvfqXdfvZ0QxbcMNHATe03f1H4PCr z5T/IdwTwljweEkj4HM1WvKdFsj68kfU/ISnmGm2m5EisCjanIArEUZRUQipiiA13xt/ q9tnKUtYYTu93RcJ5o5wgOuHSSGT8Btg6aF9lic15VggRmVky7kV54ULxJI8cKKbvfou EfUsPO8UeM/YS32QEDm5jar7F/+lJvekg+LZPTgVUqjalE9C4uxbTd5XIpEoDKCTwBKS fw+tvSp/fRHKEL6tWd5XUA/iZnVq6GTwaygU5Z9Ln492uha+g87uvoeNa48sPx7AlE3V C5Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qz24JEGG; 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 a3si4322821ilf.18.2021.09.16.20.45.03; Thu, 16 Sep 2021 20:45:15 -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=Qz24JEGG; 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 S1349354AbhIPRdP (ORCPT + 99 others); Thu, 16 Sep 2021 13:33:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:46948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348145AbhIPRX6 (ORCPT ); Thu, 16 Sep 2021 13:23:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C799261A4F; Thu, 16 Sep 2021 16:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810619; bh=cuOdGNw7f1QnFZNVV4eoDeQrIqRmu4KsyB2G/6dTrig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qz24JEGGjEYvcI+Q4v7eFlJ40HYXZTKHcAAxFLU5IGn5GtINRJ6bMCL+HjxRtkR9w 1WkXqYVzcEwoSN4Dbi1Xy/BRB+K1Us5EB7a3RIoX543AQKR0ENenOiUDoYv4ATtyyF A3WJr9JLOxDOS/KAnbidO2xunZ4NJVDqRznoy9T4= 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.14 208/432] media: platform: stm32: unprepare clocks at handling errors in probe Date: Thu, 16 Sep 2021 17:59:17 +0200 Message-Id: <20210916155817.877182487@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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