From 74152bf944837cb095c46fb4d3757086a0b94f64 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 23 May 2019 12:31:49 +0200 Subject: [PATCH] lsblk: check ul_path_scanf() return value [coverity scan] Signed-off-by: Karel Zak --- misc-utils/lsblk.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 2ad2a43392..3f8a1160f2 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -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) -- 2.39.2