From 698c6635649e50c858ca44ad258babc7c9d963f3 Mon Sep 17 00:00:00 2001 From: Akhil R Date: Mon, 13 Mar 2023 19:49:02 +0530 Subject: [PATCH] crypto: tegra: Check return value for clk_*() calls Check return value for clk_prepare_enable calls to fix the coverity issue. ID 10162284 ID 10162277 ID 10162262 Bug 3952896 Signed-off-by: Akhil R Change-Id: I881a806b1f810c1c99c068dd45196c7e9bb49f39 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2870248 Reviewed-by: Kartik . Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Rakesh Babu Bodla Reviewed-by: Bitan Biswas GVS: Gerrit_Virtual_Submit --- drivers/crypto/tegra-se-nvrng.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/tegra-se-nvrng.c b/drivers/crypto/tegra-se-nvrng.c index 46fdd02b..918aa537 100644 --- a/drivers/crypto/tegra-se-nvrng.c +++ b/drivers/crypto/tegra-se-nvrng.c @@ -3,7 +3,7 @@ * * Support for Tegra NVRNG Engine Error Handling. * - * Copyright (c) 2020-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2020-2023, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -159,6 +159,7 @@ static int tegra_se_nvrng_request_irq(struct tegra_se_nvrng_dev *nvrng_dev) static int tegra_se_nvrng_probe(struct platform_device *pdev) { struct tegra_se_nvrng_dev *nvrng_dev; + int ret; nvrng_dev = devm_kzalloc(&pdev->dev, sizeof(struct tegra_se_nvrng_dev), GFP_KERNEL); @@ -186,7 +187,11 @@ static int tegra_se_nvrng_probe(struct platform_device *pdev) if (IS_ERR(nvrng_dev->clk)) return PTR_ERR(nvrng_dev->clk); - clk_prepare_enable(nvrng_dev->clk); + ret = clk_prepare_enable(nvrng_dev->clk); + if (ret) { + dev_err(&pdev->dev, "failed to initialize clocks\n"); + return ret; + } clk_set_rate(nvrng_dev->clk, CLK_RATE); platform_set_drvdata(pdev, nvrng_dev); @@ -266,7 +271,11 @@ static int tegra_se_nvrng_suspend(struct device *dev) int ret = 0; /* 1. Enable clock */ - clk_prepare_enable(nvrng_dev->clk); + ret = clk_prepare_enable(nvrng_dev->clk); + if (ret) { + dev_err(dev, "failed to enable clocks during suspend\n"); + return ret; + } /* 2. Program NV_NVRNG_R_CTRL0_0.SW_ENGINE_ENABLED to true */ tegra_se_nvrng_writel(nvrng_dev, NV_NVRNG_R_CTRL0_0, SW_ENGINE_ENABLED); @@ -308,7 +317,11 @@ static int tegra_se_nvrng_resume(struct device *dev) int ret = 0; /* 1. Enable clock */ - clk_prepare_enable(nvrng_dev->clk); + ret = clk_prepare_enable(nvrng_dev->clk); + if (ret) { + dev_err(dev, "failed to enable clocks during resume\n"); + return ret; + } /* 2. Program NV_NVRNG_R_CTRL0_0.SW_ENGINE_ENABLED to true */ tegra_se_nvrng_writel(nvrng_dev, NV_NVRNG_R_CTRL0_0, SW_ENGINE_ENABLED);