Skip to content

Commit

Permalink
scstadmin: Eliminate use of uninitialized value in numeric error
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
bmeagherix authored and lnocturno committed Jan 30, 2024
1 parent 2f9a82b commit f4f8da8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions scstadmin/scstadmin.sysfs/scstadmin
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
}
}
}
Expand Down

0 comments on commit f4f8da8

Please sign in to comment.