[PATCH] extcon: checking the function return code

Mikhail Lobanov posted 1 patch 1 year, 4 months ago
drivers/extcon/extcon-max77693.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
[PATCH] extcon: checking the function return code
Posted by Mikhail Lobanov 1 year, 4 months ago
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@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
Re: [PATCH] extcon: checking the function return code
Posted by Krzysztof Kozlowski 1 year, 4 months ago
On 04/08/2024 15:08, Mikhail Lobanov wrote:
> This patch adds error handling for the return value of the max77693_muic_set_path function within

Please do not use "This commit/patch/change", but imperative mood. See
longer explanation here:
https://elixir.bootlin.com/linux/v5.17.1/source/Documentation/process/submitting-patches.rst#L95

Please use subject prefixes matching the subsystem. You can get them for
example with `git log --oneline -- DIRECTORY_OR_FILE` on the directory
your patch is touching. For bindings, the preferred subjects are
explained here:
https://www.kernel.org/doc/html/latest/devicetree/bindings/submitting-patches.html#i-for-patch-submitters

Please wrap commit message according to Linux coding style / submission
process (neither too early nor over the limit):
https://elixir.bootlin.com/linux/v6.4-rc1/source/Documentation/process/submitting-patches.rst#L597


> 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.

Entire commit msg is useless. Please describe the bug instead you are
fixing.

After quick look, I don't see any issue being fixed except as usual
SVACE false positives.

Many people complained already on your "reports"...


Best regards,
Krzysztof