]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - misc-utils/lsblk.c
lsblk: check ul_path_scanf() return value [coverity scan]
[thirdparty/util-linux.git] / misc-utils / lsblk.c
index 2ad2a4339227b838f8bca0b7799bdcd7b77f283e..3f8a1160f2ddb51024896a7be0eefd0c17543c0b 100644 (file)
@@ -676,12 +676,13 @@ static int is_removable_device(struct lsblk_device *dev, struct lsblk_device *pa
                if (!pc)
                        goto done;
 
+               /* dev is partition and parent is whole-disk  */
                if (pc == parent->sysfs)
-                       /* dev is partition and parent is whole-disk  */
                        dev->removable = is_removable_device(parent, NULL);
-               else
-                       /* parent is something else, use sysfs parent */
-                       ul_path_scanf(pc, "removable", "%d", &dev->removable);
+
+               /* parent is something else, use sysfs parent */
+               else if (ul_path_scanf(pc, "removable", "%d", &dev->removable) != 1)
+                       dev->removable = 0;
        }
 done:
        if (dev->removable == -1)