yaffsfs.c: Fix NULL dereference in yaffs_unmount2_reldev()
[yaffs2.git] / direct / yaffsfs.c
index 2c1ac42eba1c8cefad544e6c8f7d79d37d96674e..823f7edcfc21c9dd7e2247e1da8781e8a74eb7e1 100644 (file)
@@ -3110,14 +3110,17 @@ int yaffs_unmount2_common(struct yaffs_dev *dev, const YCHAR *path, int force)
 {
        int retVal = -1;
 
-       if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
-               yaffsfs_SetError(-EFAULT);
-               return -1;
-       }
 
-       if (yaffsfs_CheckPath(path) < 0) {
-               yaffsfs_SetError(-ENAMETOOLONG);
-               return -1;
+       if (!dev) {
+               if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
+                       yaffsfs_SetError(-EFAULT);
+                       return -1;
+               }
+
+               if (yaffsfs_CheckPath(path) < 0) {
+                       yaffsfs_SetError(-ENAMETOOLONG);
+                       return -1;
+               }
        }
 
        yaffsfs_Lock();