[lvc-project] [PATCH] extcon: checking the function return code

Mikhail Lobanov m.lobanov at rosalinux.ru
Sun Aug 4 16:08:50 MSK 2024


This patch adds error handling for the return value of the max77693_muic_set_path function within
the max77693_muic_probe function. The return value is checked to ensure that any error returned by
max77693_muic_set_path is properly handled. If the function call fails, an error message is logged 
and the probe function returns the error code.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 2b75799f5ae9 ("extcon: max77693: Set default uart/usb path by using platform data")
Signed-off-by: Mikhail Lobanov <m.lobanov at rosalinux.ru>
---
 drivers/extcon/extcon-max77693.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 2c567e0b7b7f..6a2fec47f2f1 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -1228,9 +1228,13 @@ static int max77693_muic_probe(struct platform_device *pdev)
 	cable_type = max77693_muic_get_cable_type(info,
 					   MAX77693_CABLE_GROUP_ADC, &attached);
 	if (attached && (cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_ON ||
-			 cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF))
-		max77693_muic_set_path(info, info->path_uart, true);
-
+			 cable_type == MAX77693_MUIC_ADC_FACTORY_MODE_UART_OFF)) {
+		ret = max77693_muic_set_path(info, info->path_uart, true);
+                if (ret < 0) {
+			dev_err(&pdev->dev, "failed to set path for UART: %d\n", ret);
+			return ret;
+                }
+        }
 	/* Check revision number of MUIC device*/
 	ret = regmap_read(info->max77693->regmap_muic,
 			MAX77693_MUIC_REG_ID, &id);
-- 
2.43.0




More information about the lvc-project mailing list