Skip to contentSkip to conversation

tools: two minor fixes for libxenhypfs

PATCH Applied Juergen Gross 3 participants 6 messages Jun 9, 2020

lore
Share & tools
lore
#0 lore raw

cover tools: two minor fixes for libxenhypfs

Two fixes for libxenhypfs:

- xenhypfs terminating with segfault when hypervisor doesn't have hypfs support
- wrong error reporting in case for access errors with xenhypfs

Juergen Gross (2):
tools: fix error path of xenhypfs_open()
tools: fix setting of errno in xenhypfs_read_raw()

 tools/libs/hypfs/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 tools: fix error path of xenhypfs_open()

In case of an error in xenhypfs_open() the error path will cause a segmentation fault due to a wrong sequence of closing calls.

---
 tools/libs/hypfs/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/hypfs/core.c +1 -1
index c91e165705..fc23b02586 100644
@@ -74,8 +74,8 @@ xenhypfs_handle *xenhypfs_open(xentoollog_logger *logger,
     return fshdl;
 
 err:
-    xtl_logger_destroy(fshdl->logger_tofree);
     xencall_close(fshdl->xcall);
+    xtl_logger_destroy(fshdl->logger_tofree);
     free(fshdl);
     return NULL;
 }
Signature · 1 line
2.26.2
Reviewed-by on v1 1/2
#2 lore raw

RE: [PATCH for-4.14 1/2] tools: fix error path of xenhypfs_open()

Quoted 8 lines

-----Original Message-----
From: Juergen Gross <[email protected]>
Sent: 09 June 2020 15:49
To: [email protected]
Cc: [email protected]; Juergen Gross <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; Andrew Cooper <[email protected]>
Subject: [PATCH for-4.14 1/2] tools: fix error path of xenhypfs_open()

Quoted 5 lines

In case of an error in xenhypfs_open() the error path will cause a segmentation fault due to a wrong sequence of closing calls.

Quoted 20 lines
---
 tools/libs/hypfs/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libs/hypfs/core.c +1 -2
index c91e165705..fc23b02586 100644
@@ -74,8 +74,8 @@ xenhypfs_handle *xenhypfs_open(xentoollog_logger *logger,
     return fshdl;
 
 err:
-    xtl_logger_destroy(fshdl->logger_tofree);
     xencall_close(fshdl->xcall);
+    xtl_logger_destroy(fshdl->logger_tofree);
     free(fshdl);
     return NULL;
 }
--

2.26.2

#3 lore raw

PATCH 2/2 tools: fix setting of errno in xenhypfs_read_raw()

In reply to Juergen Gross

Setting of errno is wrong in xenhypfs_read_raw(), fix it.

---
 tools/libs/hypfs/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/libs/hypfs/core.c +1 -3
index fc23b02586..f94c5ea1e2 100644
@@ -241,10 +241,8 @@ void *xenhypfs_read_raw(xenhypfs_handle *fshdl, const char *path,
         if (!ret)
             break;
 
-        if (ret != ENOBUFS) {
-            errno = -ret;
+        if (errno != ENOBUFS)
             goto out;
-        }
     }
 
     content = malloc(entry->content_len);
Signature · 1 line
2.26.2
Reviewed-by on v1 2/2
#4 lore raw

RE: [PATCH for-4.14 2/2] tools: fix setting of errno in xenhypfs_read_raw()

Quoted 8 lines

-----Original Message-----
From: Juergen Gross <[email protected]>
Sent: 09 June 2020 15:49
To: [email protected]
Cc: [email protected]; Juergen Gross <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>; George Dunlap <[email protected]>
Subject: [PATCH for-4.14 2/2] tools: fix setting of errno in xenhypfs_read_raw()

Quoted 4 lines

Setting of errno is wrong in xenhypfs_read_raw(), fix it.

Quoted 22 lines
---
 tools/libs/hypfs/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/libs/hypfs/core.c +1 -4
index fc23b02586..f94c5ea1e2 100644
@@ -241,10 +241,8 @@ void *xenhypfs_read_raw(xenhypfs_handle *fshdl, const char *path,
         if (!ret)
             break;
 
-        if (ret != ENOBUFS) {
-            errno = -ret;
+        if (errno != ENOBUFS)
             goto out;
-        }
     }
 
     content = malloc(entry->content_len);
--

2.26.2

Applied
#5 lore raw
In reply to Juergen Gross
Quoted 9 lines · Juergen Gross

Two fixes for libxenhypfs:

- xenhypfs terminating with segfault when hypervisor doesn't have hypfs support
- wrong error reporting in case for access errors with xenhypfs

Juergen Gross (2):
tools: fix error path of xenhypfs_open()
tools: fix setting of errno in xenhypfs_read_raw()

Applied. I also added Fixes tags to them.

Wei.

Quoted 7 lines
 tools/libs/hypfs/core.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.26.2