extlinux: Handle error case for find_mount()
authorMatt Fleming <matt.fleming@intel.com>
Fri, 14 Sep 2012 13:54:40 +0000 (14:54 +0100)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 14 Sep 2012 13:54:40 +0000 (14:54 +0100)
find_mount() may return NULL, so we'd really better check for that
*before* dereferencing the pointer.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
extlinux/main.c

index 73f3fbe..d7a239e 100644 (file)
@@ -915,6 +915,8 @@ static const char *find_device_mountinfo(const char *path, dev_t dev)
     struct stat st;
 
     m = find_mount(path, NULL);
+    if (!m)
+       return NULL;
 
     if (m->devpath[0] == '/' && m->dev == dev &&
        !stat(m->devpath, &st) && S_ISBLK(st.st_mode) && st.st_rdev == dev)