From f4f8da8b4dd324467e76caca1ca6f647e99a49e9 Mon Sep 17 00:00:00 2001 From: Brian Meagher Date: Wed, 24 Jan 2024 15:06:15 -0800 Subject: [PATCH] scstadmin: Eliminate use of uninitialized value in numeric error Using scstadmin to reload a configuration with fewer targets can result in a "Use of uninitialized value in numeric ne" error. Rectify by adding a check for the undefined value and handling the situation (by disabling the target in question, unless the driver is copy_manager). --- scstadmin/scstadmin.sysfs/scstadmin | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scstadmin/scstadmin.sysfs/scstadmin b/scstadmin/scstadmin.sysfs/scstadmin index 75d0ca876..84e539a61 100755 --- a/scstadmin/scstadmin.sysfs/scstadmin +++ b/scstadmin/scstadmin.sysfs/scstadmin @@ -2831,10 +2831,17 @@ sub applyConfigEnableTargets { my $t_attributes; ($t_attributes, $errorString) = $SCST->targetAttributes($driver, $target); - if (defined($$t_attributes{'enabled'}) && - ($$t_attributes{'enabled'}->{'value'} != $$attributes{'enabled'})) { - setTargetAttribute($driver, $target, 'enabled', $$attributes{'enabled'}); - $changes++; + if (defined($$attributes{'enabled'})) { + if (defined($$t_attributes{'enabled'}) && + ($$t_attributes{'enabled'}->{'value'} != $$attributes{'enabled'})) { + setTargetAttribute($driver, $target, 'enabled', $$attributes{'enabled'}); + $changes++; + } + } else { + if ($driver ne 'copy_manager') { + setTargetAttribute($driver, $target, 'enabled', 0); + $changes++; + } } } }