mcelog/backport-fix-the-buf-not-freed-in-read_field.patch
zhangruifang2020 3e0cbee7fd backport patches from upstream
(cherry picked from commit 9c5e9bc57cf2b7dba31d0dffa040ec710b4ae75f)
2023-06-16 16:40:57 +08:00

24 lines
560 B
Diff

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)