Skip to content

Commit

Permalink
otptool: Define value_start in rev_id path
Browse files Browse the repository at this point in the history
Fixes:

```
Traceback (most recent call last):
  File "/usr/bin/otptool", line 29, in <module>
    tool.run(sys.argv)
  File "/usr/lib/python3.11/site-packages/socsec/otptool.py", line 2127, in run
    args.func(args)
  File "/usr/lib/python3.11/site-packages/socsec/otptool.py", line 2130, in make_otp_image
    self.otp.make_otp_image(args.config,
  File "/usr/lib/python3.11/site-packages/socsec/otptool.py", line 1335, in make_otp_image
    config_region, config_region_ignore = self.make_config_region(
                                          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/socsec/otptool.py", line 1042, in make_config_region
    offset_value = int(value, 16) - value_start
                                    ^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'value_start' where it is not associated with a value
```

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Neal Liu neal_liu@aspeedtech.com
  • Loading branch information
amboar committed Aug 16, 2023
1 parent 078b26c commit 85b886a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions socsec/otptool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,7 @@ def make_config_region(self, config_region_config, config_info, config_region_si
bit_offset = info['bit_offset']
offset = dw_offset*32 + bit_offset
bit_length = info['bit_length']
value_start = info['value_start']
offset_value = int(value, 16) - value_start

if offset_value < 0 or offset_value > bit_length:
Expand Down

0 comments on commit 85b886a

Please sign in to comment.