Skip to contentSkip to conversation

templates/linux_xen: fix detecting xsm policy

PATCH In review Marek Marczykowski-Górecki 2 participants 4 messages Dec 13, 2022 – Dec 20, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 templates/linux_xen: fix detecting xsm policy

xsmpolicy variable was left set from previous function call. This resulted in all-but-first menu entries including XSM policy, even if it did not exist.

Fix this by initializing the xenpolicy variable.

---
 util/grub.d/20_linux_xen.in | 1 +
 1 file changed, 1 insertion(+)
util/grub.d/20_linux_xen.in +1 -0
index c1ebd0953..e46b757da 100644
@@ -105,6 +105,7 @@ linux_entry_xsm ()
   xsm="$7"
   # If user wants to enable XSM support, make sure there's
   # corresponding policy file.
+  xenpolicy=
   if ${xsm} ; then
       xenpolicy="xenpolicy-$xen_version"
       if test ! -e "${xen_dirname}/${xenpolicy}" ; then
Signature · 1 line
2.37.3
#1 lore raw
Quoted 16 lines · Marek Marczykowski-Górecki

xsmpolicy variable was left set from previous function call. This resulted in all-but-first menu entries including XSM policy, even if it did not exist.

Fix this by initializing the xenpolicy variable.

---
 util/grub.d/20_linux_xen.in | 1 +
 1 file changed, 1 insertion(+)
util/grub.d/20_linux_xen.in +0 -0
index c1ebd0953..e46b757da 100644

util/grub.d/20_linux_xen.in linux_entry_xsm () · line 108

Quoted 4 lines
util/grub.d/20_linux_xen.in +1 -0
@@ -105,6 +105,7 @@ linux_entry_xsm ()
   xsm="$7"
   # If user wants to enable XSM support, make sure there's
   # corresponding policy file.
+  xenpolicy=

Would not it be better to make this variable local? Or even better all variables (and arguments) which are used in this function only?

Daniel

#2 lore raw
Quoted 12 lines · Daniel Kiper
Quoted 11 lines · Marek Marczykowski-Górecki

xsmpolicy variable was left set from previous function call. This resulted in all-but-first menu entries including XSM policy, even if it did not exist.

Fix this by initializing the xenpolicy variable.

---
 util/grub.d/20_linux_xen.in | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

util/grub.d/20_linux_xen.in linux_entry_xsm () · line 108

Quoted 9 lines
util/grub.d/20_linux_xen.in +1 -0
index c1ebd0953..e46b757da 100644
@@ -105,6 +105,7 @@ linux_entry_xsm ()
   xsm="$7"
   # If user wants to enable XSM support, make sure there's
   # corresponding policy file.
+  xenpolicy=

Would not it be better to make this variable local? Or even better all variables (and arguments) which are used in this function only?

I considered that, but the script has #!/bin/sh, not #!/bin/bash. Isn't local a bash-specific feature?

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#3 lore raw
Quoted 26 lines · Marek Marczykowski-Górecki
Quoted 12 lines · Daniel Kiper
Quoted 11 lines · Marek Marczykowski-Górecki

xsmpolicy variable was left set from previous function call. This resulted in all-but-first menu entries including XSM policy, even if it did not exist.

Fix this by initializing the xenpolicy variable.

---
 util/grub.d/20_linux_xen.in | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

util/grub.d/20_linux_xen.in linux_entry_xsm () · line 108

Quoted 9 lines
util/grub.d/20_linux_xen.in +1 -0
index c1ebd0953..e46b757da 100644
@@ -105,6 +105,7 @@ linux_entry_xsm ()
   xsm="$7"
   # If user wants to enable XSM support, make sure there's
   # corresponding policy file.
+  xenpolicy=

Would not it be better to make this variable local? Or even better all variables (and arguments) which are used in this function only?

Quoted 2 lines

I considered that, but the script has #!/bin/sh, not #!/bin/bash. Isn't local a bash-specific feature?

Sadly you are right... :-( So, Reviewed-by: Daniel Kiper <[email protected]>...

Daniel