From 9963bb4d157c4b958735855ee3f115435a70ee9f Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 14 May 2012 21:44:31 +0200 Subject: [PATCH] fs readdir: check for NULL pointer again This got lost in: commit 6188685091c58c9772b990cf0ca6ac522f97a9d0 Author: Sascha Hauer Date: Sun May 13 12:43:58 2012 +0200 Make errno a positive value Normally errno contains a positive error value. A certain unnamed developer mixed this up while implementing U-Boot-v2. Also, normally errno is never set to zero by any library function. This patch fixes this. Signed-off-by: Sascha Hauer --- fs/fs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/fs.c b/fs/fs.c index ea5ed1158..e5ae6d532 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -1077,6 +1077,9 @@ struct dirent *readdir(DIR *dir) { struct dirent *ent; + if (!dir) + return NULL; + ent = dir->fsdrv->readdir(dir->dev, dir); if (!ent)