From fa08c3245aa9cd2bdf16b53ac5569c15ea15a268 Mon Sep 17 00:00:00 2001 From: zhangruifang2020 Date: Fri, 16 Jun 2023 15:43:43 +0800 Subject: [PATCH] backport patches from upstream (cherry picked from commit 9c5e9bc57cf2b7dba31d0dffa040ec710b4ae75f) --- ...-fix-the-buf-not-freed-in-read_field.patch | 23 ++++++++++++++ backport-fix-warnings-in-sysfs.patch | 31 +++++++++++++++++++ mcelog.spec | 11 ++++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 backport-fix-the-buf-not-freed-in-read_field.patch create mode 100644 backport-fix-warnings-in-sysfs.patch diff --git a/backport-fix-the-buf-not-freed-in-read_field.patch b/backport-fix-the-buf-not-freed-in-read_field.patch new file mode 100644 index 0000000..0d4fb29 --- /dev/null +++ b/backport-fix-the-buf-not-freed-in-read_field.patch @@ -0,0 +1,23 @@ +From 775527e886a94d89ac90239ef54e1ef436956e75 Mon Sep 17 00:00:00 2001 +From: huangduirong +Date: Sat, 9 Oct 2021 16:50:08 +0800 +Subject: [PATCH] fix the buf not freed in read_field + +--- + sysfs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysfs.c b/sysfs.c +index 7e7166e..018f294 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -39,7 +39,7 @@ char *read_field(char *base, char *name) + fd = open(fn, O_RDONLY); + free(fn); + if (fd < 0) +- goto bad; ++ goto bad_buf; + n = read(fd, buf, 4096); + close(fd); + if (n < 0) + diff --git a/backport-fix-warnings-in-sysfs.patch b/backport-fix-warnings-in-sysfs.patch new file mode 100644 index 0000000..0a56c1e --- /dev/null +++ b/backport-fix-warnings-in-sysfs.patch @@ -0,0 +1,31 @@ +From 4146c9296a0cbd26f1c5e411cb44877f350053bd Mon Sep 17 00:00:00 2001 +From: Andi Kleen +Date: Thu, 9 Dec 2021 17:12:29 -0800 +Subject: [PATCH] Fix warnings in sysfs.c + +--- + sysfs.c | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/sysfs.c b/sysfs.c +index 018f294..cd0f7c7 100644 +--- a/sysfs.c ++++ b/sysfs.c +@@ -31,7 +31,6 @@ char *read_field(char *base, char *name) + { + char *fn, *val; + int n, fd; +- struct stat st; + char *s; + char *buf = xalloc(4096); + +@@ -55,7 +54,6 @@ char *read_field(char *base, char *name) + + bad_buf: + free(buf); +-bad: + SYSERRprintf("Cannot read sysfs field %s/%s", base, name); + return xstrdup(""); + } + + diff --git a/mcelog.spec b/mcelog.spec index 164fcfe..c0964a9 100644 --- a/mcelog.spec +++ b/mcelog.spec @@ -5,7 +5,7 @@ Name: mcelog Version: 179 -Release: 3 +Release: 4 Epoch: 3 Summary: Linux kernel machine check handling middleware License: GPLv2 @@ -14,6 +14,10 @@ Source0: https://github.com/andikleen/%{name}/archive/v%{last_tar_version}.tar.g Source1: mce-inject-%{mce_inject_ver}.tar.bz2 Source2: aer-inject-%{aer_inject_ver}.tar.bz2 Source3: mcelog.conf + +Patch0:backport-fix-the-buf-not-freed-in-read_field.patch +Patch1:backport-fix-warnings-in-sysfs.patch + ExclusiveArch: i686 x86_64 BuildRequires: bison flex systemd gcc psmisc Requires(post): systemd @@ -32,6 +36,8 @@ driver error recovery handler and PCIE AER core handler. %prep %setup -q -n %{name}-%{last_tar_version} -a 1 -a 2 +%patch0 -p1 +%patch1 -p1 %build make CFLAGS="$RPM_OPT_FLAGS -Wl,-z,relro,-z,now -fpie" LDFLAGS="-Wl,-z,relro,-z,now -fpie -pie" @@ -80,6 +86,9 @@ rm -rf $RPM_BUILD_ROOT %attr(0644,root,root) %{_mandir}/*/* %changelog +* Fri Jun 16 2023 zhangruifang2020 - 3:179-4 +- backport patches from upstream + * Wed Nov 09 2022 shixuantong - 3:179-3 - enable check -- Gitee