[pve-devel] [PATCH storage 2/3] Ensure $volname is defined before using it

Daniel Berteaud daniel at firewall-services.com
Wed Sep 25 10:28:36 CEST 2019


extract_volname can return an undef $volname

Signed-off-by: Daniel Berteaud <daniel at firewall-services.com>
---
 PVE/Storage/LunCmd/LIO.pm | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/PVE/Storage/LunCmd/LIO.pm b/PVE/Storage/LunCmd/LIO.pm
index 5f9794d..5d7a21d 100644
--- a/PVE/Storage/LunCmd/LIO.pm
+++ b/PVE/Storage/LunCmd/LIO.pm
@@ -224,9 +224,11 @@ my $list_lun = sub {
     my $object = $params[0];
     my $volname = $extract_volname->($scfg, $params[0]);
 
-    foreach my $lun (@{$SETTINGS->{$scfg->{portal}.$scfg->{target}}->{luns}}) {
-	if ($lun->{storage_object} eq "$BACKSTORE/$volname") {
-	    return $object;
+    if ($volname) {
+	foreach my $lun (@{$SETTINGS->{$scfg->{portal}.$scfg->{target}}->{luns}}) {
+	    if ($lun->{storage_object} eq "$BACKSTORE/$volname") {
+		return $object;
+	    }
 	}
     }
 
-- 
2.21.0





More information about the pve-devel mailing list