From c763a745be8bc8f72eb89b5bfda34ef3bc2472f0 Mon Sep 17 00:00:00 2001 From: Klaus Wenninger Date: Thu, 16 Mar 2023 17:00:15 +0100 Subject: [PATCH] * Fri Feb 3 2023 Klaus Wenninger - 1.5.2-1 - rebase to upstream v1.5.2 - convert license naming to SPDX - make static analysis happy with a few checks & rearanges with dynamic-memory-management --- ...og-avoid-issues-on-heap-allocation-f.patch | 84 +++++++++++++++++++ ...alloc-de-alloc-reverse-order-in-slot.patch | 31 ------- ...-sbd-md-alloc-de-alloc-reverse-order.patch | 56 +++++++++++++ ...-spec-convert-license-naming-to-SPDX.patch | 34 ++++++++ sbd.spec | 22 +++-- 5 files changed, 189 insertions(+), 38 deletions(-) create mode 100644 0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch delete mode 100644 0001-Refactor-sbd-md-alloc-de-alloc-reverse-order-in-slot.patch create mode 100644 0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch create mode 100644 0003-spec-convert-license-naming-to-SPDX.patch diff --git a/0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch b/0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch new file mode 100644 index 0000000..3b0696a --- /dev/null +++ b/0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch @@ -0,0 +1,84 @@ +From 030d7edb179235b7df65ada3a79837b01e682a5b Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Thu, 21 Jul 2022 10:48:21 +0200 +Subject: [PATCH] Fix: query-watchdog: avoid issues on heap allocation failing + +coverity is moaning either due to slight code rearangement +or new version/settings. +--- + src/sbd-common.c | 27 ++++++++++++++++++++++++++- + 1 file changed, 26 insertions(+), 1 deletion(-) + +diff --git a/src/sbd-common.c b/src/sbd-common.c +index f3f226a..3abf75f 100644 +--- a/src/sbd-common.c ++++ b/src/sbd-common.c +@@ -385,8 +385,17 @@ watchdog_populate_list(void) + struct link_list_item *lli = + calloc(1, sizeof(struct link_list_item)); + ++ if (lli == NULL) { ++ break; ++ } + lli->dev_node = strdup(buf); + lli->link_name = strdup(entry_name); ++ if ((lli->dev_node == NULL) || (lli->link_name == NULL)) { ++ free(lli->dev_node); ++ free(lli->link_name); ++ free(lli); ++ break; ++ } + lli->next = link_list; + link_list = lli; + } +@@ -404,18 +413,27 @@ watchdog_populate_list(void) + if(!stat(entry_name, &statbuf) && S_ISCHR(statbuf.st_mode) && + is_watchdog(statbuf.st_rdev)) { + +- int wdfd = watchdog_init_fd(entry_name, -1); ++ int wdfd; + struct watchdog_list_item *wdg = + calloc(1, sizeof(struct watchdog_list_item)); + int len; + struct link_list_item *tmp_list = NULL; + ++ if (wdg == NULL) { ++ break; ++ } ++ + wdg->dev = statbuf.st_rdev; + wdg->dev_node = strdup(entry_name); ++ if (wdg->dev_node == NULL) { ++ free(wdg); ++ break; ++ } + wdg->next = watchdog_list; + watchdog_list = wdg; + watchdog_list_items++; + ++ wdfd = watchdog_init_fd(entry_name, -1); + if (wdfd >= 0) { + struct watchdog_info ident; + +@@ -450,11 +468,18 @@ watchdog_populate_list(void) + struct watchdog_list_item *dupe_wdg = + calloc(1, sizeof(struct watchdog_list_item)); + ++ if (dupe_wdg == NULL) { ++ break; ++ } + /* as long as we never purge watchdog_list + * there is no need to dupe strings + */ + *dupe_wdg = *wdg; + dupe_wdg->dev_node = strdup(tmp_list->link_name); ++ if (dupe_wdg->dev_node == NULL) { ++ free(dupe_wdg); ++ break; ++ } + dupe_wdg->next = watchdog_list; + watchdog_list = dupe_wdg; + watchdog_list_items++; +-- +2.39.0 + diff --git a/0001-Refactor-sbd-md-alloc-de-alloc-reverse-order-in-slot.patch b/0001-Refactor-sbd-md-alloc-de-alloc-reverse-order-in-slot.patch deleted file mode 100644 index 350c02c..0000000 --- a/0001-Refactor-sbd-md-alloc-de-alloc-reverse-order-in-slot.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 2e0890980c6e8c49f681b855c4cfe9443529d7a2 Mon Sep 17 00:00:00 2001 -From: Klaus Wenninger -Date: Sun, 30 Jan 2022 17:25:18 +0100 -Subject: [PATCH] Refactor: sbd-md: alloc/de-alloc reverse order in slot_list - -Having de-allocation in the reverse order compared to -allocation seems to make gcc-12 static analysis of -dynamic-memory-management happy. ---- - src/sbd-md.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/sbd-md.c b/src/sbd-md.c -index 47cbe8c..7a37522 100644 ---- a/src/sbd-md.c -+++ b/src/sbd-md.c -@@ -593,9 +593,9 @@ slot_list(struct sbd_context *st) - } - } - --out: free(s_node); -+out: free(s_mbox); -+ free(s_node); - free(s_header); -- free(s_mbox); - return rc; - } - --- -1.8.3.1 - diff --git a/0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch b/0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch new file mode 100644 index 0000000..81cf444 --- /dev/null +++ b/0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch @@ -0,0 +1,56 @@ +From 48c9a11e5b4ace22011e51d4c5dcacaddf9bbc43 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 3 Feb 2023 10:58:10 +0100 +Subject: [PATCH] Refactor: sbd-md: alloc/de-alloc reverse order + +Having de-allocation in the reverse order compared to +allocation seems to make gcc-12 static analysis of +dynamic-memory-management happy. +--- + src/sbd-md.c | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/src/sbd-md.c b/src/sbd-md.c +index 7a37522..2a237ad 100644 +--- a/src/sbd-md.c ++++ b/src/sbd-md.c +@@ -441,9 +441,9 @@ init_device(struct sbd_context *st) + } + } + +-out: free(s_node); ++out: free(s_mbox); ++ free(s_node); + free(s_header); +- free(s_mbox); + return(rc); + } + +@@ -556,9 +556,9 @@ slot_allocate(struct sbd_context *st, const char *name) + } + } + +-out: free(s_node); ++out: free(s_mbox); ++ free(s_node); + free(s_header); +- free(s_mbox); + return(rc); + } + +@@ -1279,11 +1279,10 @@ int servant_md(const char *diskname, int mode, const void* argp) + } + } + out: +- free(s_header); + free(s_node); + free(s_mbox); ++ free(s_header); + close_device(st); + exit(rc); + } + +- +-- +2.39.0 + diff --git a/0003-spec-convert-license-naming-to-SPDX.patch b/0003-spec-convert-license-naming-to-SPDX.patch new file mode 100644 index 0000000..5d3eddc --- /dev/null +++ b/0003-spec-convert-license-naming-to-SPDX.patch @@ -0,0 +1,34 @@ +From 0e4534ebdfe8d7a37beb0028e604e560a5674891 Mon Sep 17 00:00:00 2001 +From: Klaus Wenninger +Date: Fri, 3 Feb 2023 15:35:22 +0100 +Subject: [PATCH] spec: convert license naming to SPDX + +--- + sbd.spec | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sbd.spec b/sbd.spec +index e9ff7bc..b9e7f72 100644 +--- a/sbd.spec ++++ b/sbd.spec +@@ -49,7 +49,7 @@ + + Name: sbd + Summary: Storage-based death +-License: GPLv2+ ++License: GPL-2.0-or-later + Group: System Environment/Daemons + Version: 1.5.2 + Release: 99.%{buildnum}.%{shortcommit}.%{modified}git%{?dist} +@@ -95,7 +95,7 @@ Available rpmbuild rebuild options: + + %package tests + Summary: Storage-based death environment for regression tests +-License: GPLv2+ ++License: GPL-2.0-or-later + Group: System Environment/Daemons + + %description tests +-- +2.39.0 + diff --git a/sbd.spec b/sbd.spec index 4b303fe..b9e846b 100644 --- a/sbd.spec +++ b/sbd.spec @@ -15,11 +15,11 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -%global longcommit 6bb085f5704dd4c3841c79504f2aed2228e6d76a +%global longcommit cf5c2208bad2db2dff9b09624b89b05415c3bc11 %global shortcommit %(echo %{longcommit}|cut -c1-8) %global modified %(echo %{longcommit}-|cut -f2 -d-) %global github_owner Clusterlabs -%global buildnum 2 +%global buildnum 1 %ifarch s390x s390 # minimum timeout on LPAR diag288 watchdog is 15s @@ -47,12 +47,14 @@ Name: sbd Summary: Storage-based death -License: GPLv2+ -Version: 1.5.1 -Release: %{buildnum}%{?dist}.2 +License: GPL-2.0-or-later +Version: 1.5.2 +Release: %{buildnum}%{?dist} Url: https://github.com/%{github_owner}/%{name} Source0: https://github.com/%{github_owner}/%{name}/archive/%{longcommit}/%{name}-%{longcommit}.tar.gz -Patch0: 0001-Refactor-sbd-md-alloc-de-alloc-reverse-order-in-slot.patch +Patch0: 0001-Fix-query-watchdog-avoid-issues-on-heap-allocation-f.patch +Patch1: 0002-Refactor-sbd-md-alloc-de-alloc-reverse-order.patch +Patch2: 0003-spec-convert-license-naming-to-SPDX.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: libuuid-devel @@ -86,7 +88,7 @@ Available rpmbuild rebuild options: %package tests Summary: Storage-based death environment for regression tests -License: GPLv2+ +License: GPL-2.0-or-later %description tests This package provides an environment + testscripts for @@ -177,6 +179,12 @@ fi %{_libdir}/libsbdtestbed* %changelog +* Fri Feb 3 2023 Klaus Wenninger - 1.5.2-1 +- rebase to upstream v1.5.2 +- convert license naming to SPDX +- make static analysis happy with a few checks & rearanges with + dynamic-memory-management + * Sat Jan 21 2023 Fedora Release Engineering - 1.5.1-2.2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild