From nobody Wed Feb 11 10:48:30 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE239C7EE22 for ; Tue, 9 May 2023 09:06:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233968AbjEIJGp (ORCPT ); Tue, 9 May 2023 05:06:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjEIJGn (ORCPT ); Tue, 9 May 2023 05:06:43 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D41B40E4 for ; Tue, 9 May 2023 02:06:41 -0700 (PDT) Received: from karterlan2-VirtualBox.. ([10.12.188.37]) (user=m202271736@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 34995s5S021406-34995s5T021406 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 9 May 2023 17:05:54 +0800 From: Yi Yingao To: Vincent Shih , Srinivas Kandagatla , Greg Kroah-Hartman Cc: hust-os-kernel-patches@googlegroups.com, Yi Yingao , Dongliang Mu , linux-kernel@vger.kernel.org Subject: [PATCH] nvmem: sunplus-ocotp: release otp->clk before return Date: Tue, 9 May 2023 16:52:36 +0800 Message-Id: <20230509085237.5917-1-m202271736@hust.edu.cn> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FEAS-AUTH-USER: m202271736@hust.edu.cn Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Smatch reports: drivers/nvmem/sunplus-ocotp.c:205 sp_ocotp_probe() warn: 'otp->clk' from clk_prepare() not released on lines: 196. In the function sp_ocotp_probe(struct platform_device *pdev), otp->clk may not be released before return. To fix this issue, using function clk_unprepare() to release otp->clk. Fixes: 8747ec2e9762 ("nvmem: Add driver for OCOTP in Sunplus SP7021") Signed-off-by: Yi Yingao Reviewed-by: Dongliang Mu --- The issue is found by static analysis and the patch remains untested. --- drivers/nvmem/sunplus-ocotp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/nvmem/sunplus-ocotp.c b/drivers/nvmem/sunplus-ocotp.c index 52b928a7a6d5..f85350b17d67 100644 --- a/drivers/nvmem/sunplus-ocotp.c +++ b/drivers/nvmem/sunplus-ocotp.c @@ -192,9 +192,11 @@ static int sp_ocotp_probe(struct platform_device *pdev) sp_ocotp_nvmem_config.dev =3D dev; =20 nvmem =3D devm_nvmem_register(dev, &sp_ocotp_nvmem_config); - if (IS_ERR(nvmem)) - return dev_err_probe(&pdev->dev, PTR_ERR(nvmem), + if (IS_ERR(nvmem)) { + ret =3D dev_err_probe(&pdev->dev, PTR_ERR(nvmem), "register nvmem device fail\n"); + goto err; + } =20 platform_set_drvdata(pdev, nvmem); =20 @@ -203,6 +205,9 @@ static int sp_ocotp_probe(struct platform_device *pdev) (int)OTP_WORD_SIZE, (int)QAC628_OTP_SIZE); =20 return 0; +err: + clk_unprepare(otp->clk); + return ret; } =20 static const struct of_device_id sp_ocotp_dt_ids[] =3D { --=20 2.34.1