main - debug: stack tracing on error path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d2a2dc2e41b38f13817...
Commit: d2a2dc2e41b38f1381746ec3aa946cc52d3d8f43
Parent: 3e2827f3b79b31fc8e7370f9064c0d206aa60897
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 22:52:23 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
debug: stack tracing on error path
---
tools/pvck.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/tools/pvck.c b/tools/pvck.c
index b15158746..4aab21cee 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -3074,14 +3074,14 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
}
if (!_get_settings(cmd, &set))
- return ECMD_FAILED;
+ return_ECMD_FAILED;
if (arg_is_set(cmd, file_ARG) && (arg_is_set(cmd, repairtype_ARG) || arg_is_set(cmd, repair_ARG))) {
if (!(mf.filename = arg_str_value(cmd, file_ARG, NULL)))
- return ECMD_FAILED;
+ return_ECMD_FAILED;
if (!_read_metadata_file(cmd, &mf))
- return ECMD_FAILED;
+ return_ECMD_FAILED;
}
label_scan_setup_bcache();
@@ -3107,7 +3107,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
* reads in the filters and by _read_bytes for other disk structs.
*/
if (!dev_read_bytes(dev, 0, 4096, buf)) {
- log_error("Failed to read the first 4096 bytes of device %s.", dev_name(dev));
+ log_error("Failed to read the first 4096 bytes of device %s.", dev_name(dev));
return ECMD_FAILED;
}
@@ -3142,7 +3142,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
log_error("Unknown dump value.");
if (!ret)
- return ECMD_FAILED;
+ return_ECMD_FAILED;
return ECMD_PROCESSED;
}
@@ -3161,7 +3161,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
log_error("Unknown repair value.");
if (!ret)
- return ECMD_FAILED;
+ return_ECMD_FAILED;
return ECMD_PROCESSED;
}
@@ -3171,10 +3171,10 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
/* repair is a combination of repairtype pv_header+metadata */
if (!_repair_pv_header(cmd, "pv_header", &set, &mf, labelsector, dev))
- return ECMD_FAILED;
+ return_ECMD_FAILED;
if (!_repair_metadata(cmd, "metadata", &set, &mf, labelsector, dev))
- return ECMD_FAILED;
+ return_ECMD_FAILED;
return ECMD_PROCESSED;
}
@@ -3187,7 +3187,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
if (argc == 1)
setup_device(cmd, argv[0]);
else if (!setup_devices(cmd))
- return ECMD_FAILED;
+ return_ECMD_FAILED;
for (i = 0; i < argc; i++) {
pv_name = argv[i];
@@ -3202,6 +3202,6 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
}
if (bad)
- return ECMD_FAILED;
+ return_ECMD_FAILED;
return ECMD_PROCESSED;
}
2 years, 2 months
main - cov: add initilizer
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3e2827f3b79b31fc8e7...
Commit: 3e2827f3b79b31fc8e7370f9064c0d206aa60897
Parent: a4eb378fe41218793f4c7e97b0d82d33643b5a67
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 22:39:16 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: add initilizer
---
lib/device/dev-type.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 89791bebe..0e77a009d 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -873,7 +873,7 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
const char *offset = NULL, *type = NULL, *magic = NULL,
*usage = NULL, *label = NULL, *uuid = NULL;
loff_t offset_value;
- size_t len;
+ size_t len = 0;
if (!blkid_probe_lookup_value(probe, "TYPE", &type, NULL)) {
if (_type_in_flag_list(type, types_to_exclude))
2 years, 2 months
main - cov: add explicit check for vg existence
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a4eb378fe41218793f4...
Commit: a4eb378fe41218793f4c7e97b0d82d33643b5a67
Parent: f4b49dae1eb982e36e748fa8e1fc2af59025c9c7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 17:03:38 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: add explicit check for vg existence
Since we check !vg - add check before accessing ->status.
---
lib/format_text/format-text.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 26e55cec4..0441342a1 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -454,7 +454,7 @@ static struct volume_group *_vg_read_raw_area(struct cmd_context *cmd,
(unsigned long long)rlocn->size,
vgname);
- if (precommitted)
+ if (vg && precommitted)
vg->status |= PRECOMMITTED;
out:
2 years, 2 months
main - cov: raid: no more checks with missing areas
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f4b49dae1eb982e36e7...
Commit: f4b49dae1eb982e36e748fa8e1fc2af59025c9c7
Parent: b2db01b530e995a80abe3379019503a8cae72b10
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 17:01:17 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: raid: no more checks with missing areas
Since ->areas is directly dereferenced we need to stop
validation right here.
---
lib/metadata/merge.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index f29cf64ec..8eff74297 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -270,8 +270,10 @@ static void _check_raid_seg(struct lv_segment *seg, int *error_count)
if (!seg->area_count)
raid_seg_error("zero area count");
- if (!seg->areas)
+ if (!seg->areas) {
raid_seg_error("zero areas");
+ return;
+ }
if (seg->extents_copied > seg->len)
raid_seg_error_val("extents_copied too large", seg->extents_copied);
2 years, 2 months
main - cov: dev-mpath: check config_wwids_file
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b2db01b530e995a80ab...
Commit: b2db01b530e995a80abe3379019503a8cae72b10
Parent: b7edda8a98281b6eb400fe41f2498e031bce7ccf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 16:57:39 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: dev-mpath: check config_wwids_file
Since config_wwids_file is checked for NULL,
test is also before calling _read_wwid_file()
that is directly dereferencing it.
---
lib/device/dev-mpath.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/device/dev-mpath.c b/lib/device/dev-mpath.c
index d3eaf42a3..ba7bf9740 100644
--- a/lib/device/dev-mpath.c
+++ b/lib/device/dev-mpath.c
@@ -124,7 +124,8 @@ int dev_mpath_init(const char *config_wwids_file)
_wwid_hash_tab = wwid_tab;
- _read_wwid_file(config_wwids_file);
+ if (config_wwids_file)
+ _read_wwid_file(config_wwids_file);
return 1;
}
2 years, 2 months
main - cov: guard index
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b7edda8a98281b6eb40...
Commit: b7edda8a98281b6eb400fe41f2498e031bce7ccf
Parent: d4994915015498bc0382fc6624d2f843f865ae51
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 15:53:48 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: guard index
Analyzer wants explicit protect to not underflow index.
---
lib/activate/activate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 94fc9441d..b44efc617 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -563,7 +563,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
dm_sysfs_dir(), target_name);
if (i > 0) {
- while (path[--i] != '/') /* stop on dm_ */
+ while ((i > 0) && path[--i] != '/') /* stop on dm_ */
if (path[i] == '-')
path[i] = '_'; /* replace '-' with '_' */
2 years, 2 months
main - cov: ensure bufffe size is at least 5
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d4994915015498bc038...
Commit: d4994915015498bc0382fc6624d2f843f865ae51
Parent: 046d85af3d7a103573e56ef6861dc5d6ded9ecc7
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 15:43:23 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: ensure bufffe size is at least 5
Analyzer can now see, the buffer size will have at least 5 chars
on succefull path.
---
device_mapper/libdm-common.c | 2 +-
libdm/libdm-common.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/device_mapper/libdm-common.c b/device_mapper/libdm-common.c
index 6a2573ec4..af2178e95 100644
--- a/device_mapper/libdm-common.c
+++ b/device_mapper/libdm-common.c
@@ -1920,7 +1920,7 @@ static int _sysfs_find_kernel_name(uint32_t major, uint32_t minor, char *buf, si
continue;
if ((sz = dm_snprintf(path, sizeof(path), "%sblock/%s/dev",
- _sysfs_dir, name)) == -1) {
+ _sysfs_dir, name)) < 5) {
log_warn("Couldn't create path for %s.", name);
continue;
}
diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c
index 708414676..56fb436bc 100644
--- a/libdm/libdm-common.c
+++ b/libdm/libdm-common.c
@@ -1919,7 +1919,7 @@ static int _sysfs_find_kernel_name(uint32_t major, uint32_t minor, char *buf, si
continue;
if ((sz = dm_snprintf(path, sizeof(path), "%sblock/%s/dev",
- _sysfs_dir, name)) == -1) {
+ _sysfs_dir, name)) < 5) {
log_warn("Couldn't create path for %s.", name);
continue;
}
2 years, 2 months
main - cov: add internal error for missing arg
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=046d85af3d7a103573e...
Commit: 046d85af3d7a103573e56ef6861dc5d6ded9ecc7
Parent: 69379df8f35404269e5aa4a275a7686a87076f27
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 15:40:26 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: add internal error for missing arg
Analyzer is happier.
---
tools/lvchange.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 8293f5035..bfd464d5c 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1685,6 +1685,11 @@ static int _lvchange_syncaction_single(struct cmd_context *cmd,
{
const char *msg = arg_str_value(cmd, syncaction_ARG, NULL);
+ if (!msg) {
+ log_error(INTERNAL_ERROR "Missing syncaction arg.");
+ return ECMD_FAILED;
+ }
+
if (lv_raid_has_integrity(lv) && !strcmp(msg, "repair")) {
log_error("Use syncaction check to detect and correct integrity checksum mismatches.");
return ECMD_FAILED;
2 years, 2 months
main - cov: remove unneeded includes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=69379df8f35404269e5...
Commit: 69379df8f35404269e5aa4a275a7686a87076f27
Parent: ec9dd728aa00de692f4b003e12394aa9cdda9446
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 15:04:09 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:28 2021 +0200
cov: remove unneeded includes
---
lib/filters/filter-mpath.c | 2 --
lib/metadata/lv_manip.c | 1 -
lib/metadata/pv_manip.c | 1 -
3 files changed, 4 deletions(-)
diff --git a/lib/filters/filter-mpath.c b/lib/filters/filter-mpath.c
index ebd40a457..982e23400 100644
--- a/lib/filters/filter-mpath.c
+++ b/lib/filters/filter-mpath.c
@@ -15,8 +15,6 @@
#include "base/memory/zalloc.h"
#include "lib/misc/lib.h"
#include "lib/filters/filter.h"
-#include "lib/activate/activate.h"
-#include "lib/commands/toolcontext.h"
#ifdef __linux__
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 7e66afd9c..a26d3d533 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -23,7 +23,6 @@
#include "lib/metadata/pv_alloc.h"
#include "lib/display/display.h"
#include "lib/metadata/segtype.h"
-#include "lib/format_text/archiver.h"
#include "lib/activate/activate.h"
#include "lib/datastruct/str_list.h"
#include "lib/config/defaults.h"
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index cfc983174..2b970f0ba 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -20,7 +20,6 @@
#include "lib/locking/locking.h"
#include "lib/config/defaults.h"
#include "lib/display/display.h"
-#include "lib/format_text/archiver.h"
static struct pv_segment *_alloc_pv_segment(struct dm_pool *mem,
struct physical_volume *pv,
2 years, 2 months
main - cov: memleak dir descriptor
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ec9dd728aa00de692f4...
Commit: ec9dd728aa00de692f4b003e12394aa9cdda9446
Parent: 308c6f31c3d79b370b163660f3ec38042a00289f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 27 15:36:48 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jul 28 00:49:22 2021 +0200
cov: memleak dir descriptor
opendir() missed closedir().
---
lib/device/dev-type.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 067a9ffad..89791bebe 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -180,6 +180,9 @@ int dev_is_used_by_active_lv(struct cmd_context *cmd, struct device *dev, int *u
}
}
+ if (closedir(d))
+ log_sys_debug("closedir", holders_path);
+
if (used_by_lv_count)
*used_by_lv_count = used_count;
if (used_by_dm_name)
2 years, 2 months