Skip to contentSkip to conversation

libxl: init_acpi_config should return rc in exit path

PATCH In review Wei Liu 4 participants 12 messages Dec 14, 2016 – Dec 16, 2016

lore
Share & tools
lore

Wei Liu

author
#0 lore raw

PATCH 1/1 libxl: init_acpi_config should return rc in exit path

... otherwise it returns 0 even if the function fails.

---
Cc: Ian Jackson <[email protected]>

This should be backported to 4.8.

---
 tools/libxl/libxl_x86_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_x86_acpi.c +1 -1
index 686ac8e..6cf0c30 100644
@@ -154,7 +154,7 @@ static int init_acpi_config(libxl__gc *gc,
     config->acpi_revision = 5;
 
 out:
-    return 0;
+    return rc;
 }
 
 int libxl__dom_load_acpi(libxl__gc *gc,
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Wei Liu

... otherwise it returns 0 even if the function fails.

Coverity-ID: 1397121

Quoted 1 line
Quoted 13 lines

---
Cc: Ian Jackson <[email protected]>

This should be backported to 4.8.

---
 tools/libxl/libxl_x86_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_x86_acpi.c +0 -0
index 686ac8e..6cf0c30 100644

tools/libxl/libxl_x86_acpi.c static int init_acpi_config(libxl__gc *gc, · line 160

Quoted 8 lines
tools/libxl/libxl_x86_acpi.c +1 -1
@@ -154,7 +154,7 @@ static int init_acpi_config(libxl__gc *gc,
     config->acpi_revision = 5;
 
 out:
-    return 0;
+    return rc;
 }
 
 int libxl__dom_load_acpi(libxl__gc *gc,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#2 lore raw
Quoted 5 lines · Andrew Cooper
Quoted 1 line · Wei Liu

... otherwise it returns 0 even if the function fails.

Coverity-ID: 1397121

Does it work this way? Coverity does lead to the discovery of this bug, but this CID doesn't reveal the bug directly.

Quoted 19 lines
Quoted 1 line
Quoted 15 lines

---
Cc: Ian Jackson <[email protected]>

This should be backported to 4.8.

---
 tools/libxl/libxl_x86_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_x86_acpi.c +0 -0
index 686ac8e..6cf0c30 100644
@@ -154,7 +154,7 @@ static int init_acpi_config(libxl__gc *gc,
     config->acpi_revision = 5;
 
Quoted 7 lines

tools/libxl/libxl_x86_acpi.c static int init_acpi_config(libxl__gc *gc, · line 160

Quoted 6 lines
tools/libxl/libxl_x86_acpi.c +1 -1
 out:
-    return 0;
+    return rc;
 }
 
 int libxl__dom_load_acpi(libxl__gc *gc,

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
In reply to Andrew Cooper
Quoted 24 lines · Andrew Cooper
Quoted 1 line · Wei Liu

... otherwise it returns 0 even if the function fails.

Coverity-ID: 1397121

Quoted 1 line
Quoted 15 lines

---
Cc: Ian Jackson <[email protected]>

This should be backported to 4.8.

---
 tools/libxl/libxl_x86_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_x86_acpi.c +0 -0
index 686ac8e..6cf0c30 100644
@@ -154,7 +154,7 @@ static int init_acpi_config(libxl__gc *gc,
     config->acpi_revision = 5;
 
Quoted 3 lines

tools/libxl/libxl_x86_acpi.c static int init_acpi_config(libxl__gc *gc, · line 157

Quoted 3 lines
tools/libxl/libxl_x86_acpi.c +1 -1
 out:
-    return 0;
+    return rc;

This breaks init_acpi_config(): xc_domain_getinfo() at the top of returns a positive number (number of domains).

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#4 lore raw
Quoted 25 lines · Boris Ostrovsky
Quoted 24 lines · Andrew Cooper
Quoted 1 line · Wei Liu

... otherwise it returns 0 even if the function fails.

Coverity-ID: 1397121

Quoted 1 line
Quoted 15 lines

---
Cc: Ian Jackson <[email protected]>

This should be backported to 4.8.

---
 tools/libxl/libxl_x86_acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/libxl/libxl_x86_acpi.c +0 -0
index 686ac8e..6cf0c30 100644
@@ -154,7 +154,7 @@ static int init_acpi_config(libxl__gc *gc,
     config->acpi_revision = 5;
 
Quoted 7 lines
Quoted 3 lines

tools/libxl/libxl_x86_acpi.c static int init_acpi_config(libxl__gc *gc, · line 157

Quoted 3 lines
tools/libxl/libxl_x86_acpi.c +1 -1
 out:
-    return 0;
+    return rc;

This breaks init_acpi_config(): xc_domain_getinfo() at the top of returns a positive number (number of domains).

I see, I think we also need to set rc=0 in the success path.

Wei.

Quoted 3 lines

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#6 lore raw
Quoted 6 lines · Boris Ostrovsky
Quoted 2 lines · Wei Liu

I see, I think we also need to set rc=0 in the success path.

Or 'return rc < 0 ? rc : 0;'

I don't think so, because there could be functions that only return >0 values to indicate error.

Wei.

Quoted 1 line

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#7 lore raw

Wei Liu writes ("Re: [Xen-devel] [PATCH] libxl: init_acpi_config should return rc in exit path"):

Quoted 2 lines

I don't think so, because there could be functions that only return >0 values to indicate error.

The problem here is the violation of the CODING_STYLE which forbids the use of `rc' to contain anything other than a libxl error value.

`r' should be used for the values from libxc. And each failure path should set rc.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Acked-by on v1 1/1
#8 lore raw
In reply to Wei Liu

Wei Liu writes ("[PATCH] libxl: init_acpi_config should return rc in exit path"):

Quoted 1 line

... otherwise it returns 0 even if the function fails.

FTR, I'm happy for obvious patches from you, like this one, to go in without waiting for my ack!

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#9 lore raw
Quoted 5 lines · Ian Jackson

Wei Liu writes ("[PATCH] libxl: init_acpi_config should return rc in exit path"):

Quoted 1 line

... otherwise it returns 0 even if the function fails.

Thanks.

Quoted 3 lines

FTR, I'm happy for obvious patches from you, like this one, to go in without waiting for my ack!

Noted.

Quoted 2 lines

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

author
#10 lore raw
In reply to Wei Liu
Quoted 7 lines · Wei Liu

... otherwise it returns 0 even if the function fails.

---
Cc: Ian Jackson <[email protected]>

This should be backported to 4.8.

And please don't just apply this one patch because it is buggy.

You would also need "libxl: set rc to 0 in init_acpi_config in success path".

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#11 lore raw

Wei Liu writes ("Re: [PATCH] libxl: init_acpi_config should return rc in exit path"):

Quoted 5 lines

And please don't just apply this one patch because it is buggy.

You would also need "libxl: set rc to 0 in init_acpi_config in success path".

Noted, thanks.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel