Skip to contentSkip to conversation

serial: s5p: Fix clk_get_by_index() error code check

PATCH In review Sam Protsenko 2 participants 2 messages Nov 7, 2023 – Nov 14, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: s5p: Fix clk_get_by_index() error code check

clk_get_by_index() returns negative number on error. Assigning it to unsigned int makes the subsequent "ret < 0" check always false, leading in turn to possible unhandled errors. Change 'ret' variable type to signed int so the code checks and handles clk_get_by_index() return code properly.

Fixes cf75cdf96ef2 ("serial: s5p: use clock api to get clock rate")
---
 drivers/serial/serial_s5p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_s5p.c +1 -1
index 7aeb8c0f8cb7..fe52580d64de 100644
@@ -118,7 +118,7 @@ int s5p_serial_setbrg(struct udevice *dev, int baudrate)
 
 #if IS_ENABLED(CONFIG_CLK_EXYNOS) || IS_ENABLED(CONFIG_ARCH_APPLE)
 	struct clk clk;
-	u32 ret;
+	int ret;
 
 	ret = clk_get_by_index(dev, 1, &clk);
 	if (ret < 0)
Signature · 1 line
2.39.2
#1 lore raw

Hi

2023년 11월 8일 (수) 03:39, Sam Protsenko <[email protected]>님이 작성:

Quoted 26 lines

clk_get_by_index() returns negative number on error. Assigning it to unsigned int makes the subsequent "ret < 0" check always false, leading in turn to possible unhandled errors. Change 'ret' variable type to signed int so the code checks and handles clk_get_by_index() return code properly.

Fixes cf75cdf96ef2 ("serial: s5p: use clock api to get clock rate")
---
 drivers/serial/serial_s5p.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/serial/serial_s5p.c +1 -1
index 7aeb8c0f8cb7..fe52580d64de 100644
@@ -118,7 +118,7 @@ int s5p_serial_setbrg(struct udevice *dev, int
 baudrate)
 
 #if IS_ENABLED(CONFIG_CLK_EXYNOS) || IS_ENABLED(CONFIG_ARCH_APPLE)
        struct clk clk;
-       u32 ret;
+       int ret;
 
        ret = clk_get_by_index(dev, 1, &clk);
        if (ret < 0)
Quoted 3 lines

--
2.39.2

applied to u-boot-samsung.

Thanks.
Minkyu Kang.