Multiple devices with the same disk UUID shouldn't happen and if it does, the existing code is not equipped to handle that.
Change it, so only the first _disk_ is considered. diskuuid is in a union with partuuid and that could lead to cdev partition being taken as backend storage instead. Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- drivers/misc/storage-by-uuid.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/misc/storage-by-uuid.c b/drivers/misc/storage-by-uuid.c index 8b8fd901685e..7bb987dffbec 100644 --- a/drivers/misc/storage-by-uuid.c +++ b/drivers/misc/storage-by-uuid.c @@ -143,10 +143,14 @@ static void check_exist(struct sbu *sbu) struct cdev *cdev; for_each_cdev(cdev) { - if (!strcmp(cdev->diskuuid, sbu->uuid)) { - dev_dbg(sbu->dev, "Found %s %s\n", cdev->name, cdev->diskuuid); - storage_by_uuid_add_partitions(sbu, cdev); - } + if (cdev_is_partition(cdev)) + continue; + if (strcmp(cdev->diskuuid, sbu->uuid)) + continue; + + dev_dbg(sbu->dev, "Found %s %s\n", cdev->name, cdev->diskuuid); + storage_by_uuid_add_partitions(sbu, cdev); + return; } } -- 2.39.5