backport patches from upstream

(cherry picked from commit 9c5e9bc57cf2b7dba31d0dffa040ec710b4ae75f)
This commit is contained in:
zhangruifang2020 2023-06-16 15:43:43 +08:00 committed by openeuler-sync-bot
parent a076a9e666
commit 3e0cbee7fd
3 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,23 @@
From 775527e886a94d89ac90239ef54e1ef436956e75 Mon Sep 17 00:00:00 2001
From: huangduirong <huangduirong@huawei.com>
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)

View File

@ -0,0 +1,31 @@
From 4146c9296a0cbd26f1c5e411cb44877f350053bd Mon Sep 17 00:00:00 2001
From: Andi Kleen <ak@linux.intel.com>
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("");
}

View File

@ -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 <zhangruifang1@h-partners.com> - 3:179-4
- backport patches from upstream
* Wed Nov 09 2022 shixuantong <shixuantong1@huaweic.om> - 3:179-3
- enable check