From d50e7a71cb5f8ecfbe2eb69c163d532bab82cbf0 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Tue, 4 Jan 2022 15:25:04 +0100 Subject: [PATCH] fix(st-sdmmc2): check regulator enable/disable return The issue was reported by Coverity [1]. The return of the functions regulator_disable() and regulator_enable() was not checked. If they fail, this means there is an issue either with PMIC or I2C. The board should the stop booting with a panic(). [1] https://scan4.scan.coverity.com/reports.htm#v47771/p11439/mergedDefectId=374565 Change-Id: If5dfd5643c210e03ae4b1f4cab0168c0db89f60e Signed-off-by: Yann Gautier --- drivers/st/mmc/stm32_sdmmc2.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/st/mmc/stm32_sdmmc2.c b/drivers/st/mmc/stm32_sdmmc2.c index 1a8bd5bb6..dbdaa545d 100644 --- a/drivers/st/mmc/stm32_sdmmc2.c +++ b/drivers/st/mmc/stm32_sdmmc2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, STMicroelectronics - All Rights Reserved + * Copyright (c) 2018-2022, STMicroelectronics - All Rights Reserved * * SPDX-License-Identifier: BSD-3-Clause */ @@ -157,13 +157,17 @@ static void stm32_sdmmc2_init(void) uint32_t clock_div; uint32_t freq = STM32MP_MMC_INIT_FREQ; uintptr_t base = sdmmc2_params.reg_base; + int ret; if (sdmmc2_params.max_freq != 0U) { freq = MIN(sdmmc2_params.max_freq, freq); } if (sdmmc2_params.vmmc_regu != NULL) { - regulator_disable(sdmmc2_params.vmmc_regu); + ret = regulator_disable(sdmmc2_params.vmmc_regu); + if (ret < 0) { + panic(); + } } mdelay(VCC_POWER_OFF_DELAY); @@ -173,7 +177,10 @@ static void stm32_sdmmc2_init(void) mdelay(POWER_CYCLE_DELAY); if (sdmmc2_params.vmmc_regu != NULL) { - regulator_enable(sdmmc2_params.vmmc_regu); + ret = regulator_enable(sdmmc2_params.vmmc_regu); + if (ret < 0) { + panic(); + } } mdelay(VCC_POWER_ON_DELAY);