summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--volumes.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/volumes.c b/volumes.c
index 2209e5a9..2fde4762 100644
--- a/volumes.c
+++ b/volumes.c
@@ -138,7 +138,21 @@ static int device_list_add(const char *path,
list_add(&device->dev_list, &fs_devices->devices);
device->fs_devices = fs_devices;
} else if (!device->name || strcmp(device->name, path)) {
- char *name = strdup(path);
+ char *name;
+
+ /*
+ * The existing device has newer generation, so this one could
+ * be a stale one, don't add it.
+ */
+ if (found_transid < device->generation) {
+ warning(
+ "adding device %s gen %llu but found an existing device %s gen %llu",
+ path, found_transid, device->name,
+ device->generation);
+ return -EEXIST;
+ }
+
+ name = strdup(path);
if (!name)
return -ENOMEM;
kfree(device->name);