From abafccd6403a709d6d8da4d3bc666b86686e45e5 Mon Sep 17 00:00:00 2001 From: luckky Date: Mon, 4 Nov 2024 18:28:29 +0800 Subject: [PATCH] fix write file return code bug --- fix-write-file-return-code-bug.patch | 69 ++++++++++++++++++++++++++++ sysSentry.spec | 9 +++- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 fix-write-file-return-code-bug.patch diff --git a/fix-write-file-return-code-bug.patch b/fix-write-file-return-code-bug.patch new file mode 100644 index 0000000..f059224 --- /dev/null +++ b/fix-write-file-return-code-bug.patch @@ -0,0 +1,69 @@ +From cea094acea79b88e6458cfa264a03c51f08c72fc Mon Sep 17 00:00:00 2001 +From: luckky +Date: Mon, 4 Nov 2024 20:18:05 +0800 +Subject: [PATCH] fix write file return code bug +Set the return code 0 to -EINVAL to unify the processing of return code. + +--- + .../hbm_online_repair/non-standard-hbm-repair.c | 17 ++++++++++------- + 1 file changed, 10 insertions(+), 7 deletions(-) + +diff --git a/src/c/hbm_online_repair/non-standard-hbm-repair.c b/src/c/hbm_online_repair/non-standard-hbm-repair.c +index b8dde7a..97cb9a7 100644 +--- a/src/c/hbm_online_repair/non-standard-hbm-repair.c ++++ b/src/c/hbm_online_repair/non-standard-hbm-repair.c +@@ -112,7 +112,7 @@ static void parse_fault_addr_info(struct fault_addr_info* info_struct, unsigned + info_struct->row_id = fault_addr & FAULT_ADDR_ROW_ID_MASK; + fault_addr >>= FAULT_ADDR_ROW_ID_LEN; + info_struct->column_id = fault_addr & FAULT_ADDR_COLUMN_ID_MASK; +- fault_addr >>= FAULT_ADDR_CHANNEL_ID_LEN; ++ fault_addr >>= FAULT_ADDR_COLUMN_ID_LEN; + info_struct->error_type = fault_addr & FAULT_ADDR_ERROR_TYPE_MASK; + fault_addr >>= FAULT_ADDR_ERROR_TYPE_LEN; + info_struct->repair_type = fault_addr & FAULT_ADDR_REPAIR_TYPE_MASK; +@@ -371,7 +371,12 @@ static int write_file(char *path, const char *name, unsigned long long value) + fname, value, strerror(errno)); + + close(fd); +- return ret > 0 ? 0 : -errno; ++ if (ret == 0) { ++ ret = -EINVAL; ++ } else if (ret < 0) { ++ ret = -errno; ++ } ++ return ret; + } + + static int get_hardware_corrupted_size() +@@ -560,7 +565,7 @@ static int hbmc_hbm_page_isolate(const struct hisi_common_error_section *err) + static uint8_t hbmc_hbm_after_repair(bool is_acls, const int repair_ret, const unsigned long long paddr) + { + int ret; +- if (repair_ret <= 0) { ++ if (repair_ret < 0) { + log(LOG_WARNING, "HBM %s: Keep page (0x%llx) offline\n", is_acls ? "ACLS" : "SPPR", paddr); + /* not much we can do about errors here */ + (void)write_file("/sys/kernel/page_eject", "remove_page", paddr); +@@ -594,8 +599,7 @@ static int hbmc_hbm_repair(const struct hisi_common_error_section *err, char *pa + + ret = write_file(path, is_acls ? "acls_query" : "sppr_query", paddr); + +- /* Only positive num means the error is supported to repair */ +- if (ret <= 0) { ++ if (ret < 0) { + if (ret != -ENXIO) { + notice_BMC(err, get_repair_failed_result_code(ret)); + log(LOG_WARNING, "HBM: Address 0x%llx is not supported to %s repair\n", paddr, is_acls ? "ACLS" : "SPPR"); +@@ -624,8 +628,7 @@ static int hbmc_hbm_repair(const struct hisi_common_error_section *err, char *pa + all_online_success = false; + } + } +- /* The ret is from the acls/sppr repair, and only positive num means the error is repaired successfully */ +- if (ret <= 0) { ++ if (ret < 0) { + notice_BMC(err, get_repair_failed_result_code(ret)); + return ret; + } else if (all_online_success) { +-- +2.43.0 + diff --git a/sysSentry.spec b/sysSentry.spec index c0ae1c3..bf78902 100644 --- a/sysSentry.spec +++ b/sysSentry.spec @@ -4,7 +4,7 @@ Summary: System Inspection Framework Name: sysSentry Version: 1.0.2 -Release: 57 +Release: 58 License: Mulan PSL v2 Group: System Environment/Daemons Source0: https://gitee.com/openeuler/sysSentry/releases/download/v%{version}/%{name}-%{version}.tar.gz @@ -77,6 +77,7 @@ Patch64: get_alarm-d-abnomal-display.patch Patch65: modify-logrotate-rule.patch Patch66: fix-excessive-CPU-usage.patch Patch67: fix-uint8-bug-and-change-isolation-default-value.patch +Patch68: fix-write-file-return-code-bug.patch BuildRequires: cmake gcc-c++ BuildRequires: python3 python3-setuptools @@ -370,6 +371,12 @@ rm -rf %{buildroot} %attr(0550,root,root) %{python3_sitelib}/syssentry/bmc_alarm.py %changelog +* Mon Nov 4 2024 luckky - 1.0.2-58 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:fix write file return code bug + * Fri Nov 1 2024 luckky - 1.0.2-57 - Type:bugfix - CVE:NA -- Gitee