commit c977a585663c21494c76fbe691b177669172793a
parent 895c6ce13608b721fc8cfd04f4ea8a397d1bc87b
Author: Roberto E. Vargas Caballero <roberto@clue.aero>
Date: Mon, 12 Aug 2019 14:40:04 +0200
[dev] Check return value of namec()
Namec can return NULL if the path is wrong. Open()
was not checking this condition and it was generating
a segfault when it was accesing it after calling
chan2fd().
Change-Id: Iba3b9f6d9d1ab0526cdab768431cdbb12879cfa3
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/dev.c b/drivers/dev.c
@@ -375,7 +375,8 @@ open(const char *fname, int mode)
if (!validmode(mode))
return -1;
- c = namec(fname, mode);
+ if ((c = namec(fname, mode)) == NULL)
+ return -1;
r = chan2fd(c);
unlock(&c->mutex);