Skip to content

Commit 6394797

Browse files
GuEe-GUIRbb666
authored andcommitted
[dm][serial] Fixup serial tty check
Just return if is not a tty device, don't assert Signed-off-by: GuEe-GUI <[email protected]>
1 parent cb808f3 commit 6394797

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

components/drivers/serial/serial_tty.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ static char *alloc_device_name(struct rt_serial_device *serial)
6262
* must be obtained using the serial_dev_set_name function,
6363
* and it should begin with "uart".
6464
*/
65-
RT_ASSERT((strlen(serial_name) > strlen("uart")) && (strncmp(serial_name, "uart", 4) == 0));
65+
if (!serial_name || rt_strlen(serial_name) < 4 || rt_strncmp(serial_name, "uart", 4))
66+
{
67+
return RT_NULL;
68+
}
69+
6670
long digits_len = (sizeof(TTY_NAME_PREFIX) - 1) /* raw prefix */
6771
+ strlen(serial_name + sizeof("uart") - 1) /* suffix of serial device name*/
6872
+ 1; /* tailing \0 */

0 commit comments

Comments
 (0)