diff --git a/tty.c b/tty.c index f1f1e28b..0d0f736a 100644 --- a/tty.c +++ b/tty.c @@ -50,8 +50,12 @@ typedef struct node { LIST_HEAD(, node) node_list = LIST_HEAD_INITIALIZER(); int tty_add(char *tty, int baud) { - node_t *entry = malloc(sizeof(*entry)); + node_t *entry; + if (!tty) + return errno = EINVAL; + + entry = malloc(sizeof(*entry)); if (!entry) return errno = ENOMEM;