core: fs: verify call to fs_ops->readdir
authorSebastian Herbszt <herbszt@gmx.de>
Sun, 7 Mar 2010 15:02:50 +0000 (16:02 +0100)
committerH. Peter Anvin <hpa@linux.intel.com>
Thu, 1 Apr 2010 23:04:27 +0000 (16:04 -0700)
Check if fs_ops->readdir is available before calling it.
At least PXELINUX doesn't implement it.

Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
LKML-Reference: <1267974170$3058@local>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
core/fs/readdir.c

index d2b112b..d20fc33 100644 (file)
@@ -28,8 +28,11 @@ struct dirent *readdir(DIR *dir)
     struct file *dd_dir = (struct file *)dir;
     int rv = -1;
     
-    if (dd_dir)
-       rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf);
+    if (dd_dir) {
+        if (dd_dir->fs->fs_ops->readdir) {
+           rv = dd_dir->fs->fs_ops->readdir(dd_dir, &buf);
+        }
+    }
 
     return rv < 0 ? NULL : &buf;
 }