Skip to contentSkip to conversation

tools/bootconfig: Fix apply_xbc() to return zero on success

PATCH In review Steven Rostedt 2 participants 4 messages May 8, 2020 – May 9, 2020 Extra boot config

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/bootconfig: Fix apply_xbc() to return zero on success

From: "Steven Rostedt (VMware)" <[email protected]>

The return of apply_xbc() returns the result of the last write() call, which is not what is expected. It should only return zero on success.

Fixes 8842604446d1 ("tools/bootconfig: Fix resource leak in apply_xbc()")
---
 tools/bootconfig/main.c | 1 +
 1 file changed, 1 insertion(+)
tools/bootconfig/main.c +1 -0
index 001076c51712..0efaf45f7367 100644
@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)
 		pr_err("Failed to apply a boot config magic: %d\n", ret);
 		goto out;
 	}
+	ret = 0;
 out:
 	close(fd);
 	free(data);
Signature · 1 line
2.20.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On Fri, 8 May 2020 11:13:49 -0400 Steven Rostedt <[email protected]> wrote:

From: "Steven Rostedt (VMware)" <[email protected]>

The return of apply_xbc() returns the result of the last write() call, which is not what is expected. It should only return zero on success.

Thanks for fixing!

Quoted 22 lines
Fixes 8842604446d1 ("tools/bootconfig: Fix resource leak in apply_xbc()")
---
 tools/bootconfig/main.c | 1 +
 1 file changed, 1 insertion(+)
tools/bootconfig/main.c +1 -0
index 001076c51712..0efaf45f7367 100644
@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)
 		pr_err("Failed to apply a boot config magic: %d\n", ret);
 		goto out;
 	}
+	ret = 0;
 out:
 	close(fd);
 	free(data);
Signature · 1 line
2.20.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer Tested-by
#2 lore raw
Quoted 8 lines · On Sat, 9 May 2020 08:14:24 +0900 Masami Hiramatsu <[email protected]> wrote:
Quoted 5 lines · On Fri, 8 May 2020 11:13:49 -0400 Steven Rostedt <[email protected]> wrote:

From: "Steven Rostedt (VMware)" <[email protected]>

The return of apply_xbc() returns the result of the last write() call, which is not what is expected. It should only return zero on success.

Quoted 7 lines
Quoted 2 lines

Thanks for fixing!

Oh, and tested too.

---
...
test case 40 (samples/good-tree.bconf)...
Apply samples/good-tree.bconf to ./initrd-tNhd

	Number of nodes: 16
	Size: 136 bytes
	Checksum: 9171
		[OK]

All tests passed
---

BTW, I might better add a test summary to the test script (and move it into kselftest?)

Thank you,

Quoted 27 lines
Quoted 23 lines
Fixes 8842604446d1 ("tools/bootconfig: Fix resource leak in apply_xbc()")
---
 tools/bootconfig/main.c | 1 +
 1 file changed, 1 insertion(+)
tools/bootconfig/main.c +1 -0
index 001076c51712..0efaf45f7367 100644
@@ -337,6 +337,7 @@ int apply_xbc(const char *path, const char *xbc_path)
 		pr_err("Failed to apply a boot config magic: %d\n", ret);
 		goto out;
 	}
+	ret = 0;
 out:
 	close(fd);
 	free(data);
Signature · 1 line
2.20.1
Signature · 1 line
Masami Hiramatsu <[email protected]>
Signature · 1 line
Masami Hiramatsu <[email protected]>
maintainer
#3 lore raw

PATCH 1/1 tools/bootconfig: Add a summary of test cases and return error

Add summary lines of test cases and return an error code if any test case fails so that tester don't have to monitor the output.

---
 tools/bootconfig/test-bootconfig.sh |    7 +++++++
 1 file changed, 7 insertions(+)
tools/bootconfig/test-bootconfig.sh +7 -0
index 81b350ffd03f..eff16b77d5eb 100755
@@ -124,9 +124,16 @@ for i in samples/good-* ; do
   xpass $BOOTCONF -a $i $INITRD
 done
 
+
+echo
+echo "=== Summary ==="
+echo "# of Passed: $(expr $NO - $NG - 1)"
+echo "# of Failed: $NG"
+
 echo
 if [ $NG -eq 0 ]; then
 	echo "All tests passed"
 else
 	echo "$NG tests failed"
+	exit 1
 fi