block: Check strdup() fail case 15/307115/2 accepted/tizen/unified/20240306.174207 accepted/tizen/unified/dev/20240620.005812 accepted/tizen/unified/toolchain/20240311.065622 accepted/tizen/unified/x/20240308.033423
authorUnsung Lee <unsung.lee@samsung.com>
Tue, 5 Mar 2024 04:38:40 +0000 (13:38 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Tue, 5 Mar 2024 11:15:18 +0000 (20:15 +0900)
Check whether strdup() is called successfully or not to
avoid NULL pointer into strlen().

This bug is reported by SVACE with id = 695575.

Change-Id: I9fdb6ab681085c13fccebe51fd72c72e25bc859e
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
src/block/block.c

index e70f4624bfb9a025b0cc2e28ebb3c129be092a85..7aa6ee56253c2178491a246f0509f2254819232c 100644 (file)
@@ -1999,6 +1999,9 @@ static int find_thread(char *devnode)
        } else
                th_node = strdup(devnode);
 
+       if (th_node == NULL)
+               return -1;
+
        len = strlen(th_node) + 1;
        min_num = 1000;
        min = -1;