From 263036045a07914c7e54ab774532c08d5a3f9422 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Wed, 22 May 2013 12:36:12 +0200 Subject: [PATCH] tty: Check input arguments for invalid tty before adding. Signed-off-by: Joachim Nilsson --- tty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;