libfstools: ubi: avoid crash in volume finding function
[project/fstools.git] / libfstools / ubi.c
index 866034a..ac9eb1b 100644 (file)
@@ -143,6 +143,10 @@ static int ubi_volume_match(struct volume *v, char *name, int ubi_num, int volid
        /* todo: skip existing gluebi device for legacy support */
 
        volname = read_string_from_file(voldir, "name");
+       if (!volname) {
+               fprintf(stderr, "Couldn't read %s/name\n", voldir);
+               return -1;
+       }
 
        if (strncmp(name, volname, strlen(volname) + 1))
                return -1;