Skip to content

Commit c9ef907

Browse files
authored
fix: avoid potential index out of range error if ls-iommu cannot find a vbios path (#31)
1 parent 276cfd9 commit c9ef907

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/pages/03_vbios_extract.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ func genVBIOS_dumper(config *configs.Config) {
2626
scriptdir, _ = os.Getwd()
2727
}
2828

29-
// Get the vbios path and generate the vbios dumping script
30-
vbios_path := lsiommu.GetIOMMU("-g", "-i", config.Gpu_Group, "--rom")[0]
31-
configs.GenerateVBIOSDumper(vbios_path)
29+
// Search for a vbios path and generate the vbios dumping script if found
30+
vbios_paths := lsiommu.GetIOMMU("-g", "-i", config.Gpu_Group, "--rom")
31+
if len(vbios_paths) != 0 {
32+
configs.GenerateVBIOSDumper(vbios_paths[0])
33+
}
3234

3335
// Make the qemu config folder
3436
os.Mkdir(fmt.Sprintf("%s/%s", scriptdir, config.Path.QEMU), os.ModePerm)
@@ -51,7 +53,7 @@ func genVBIOS_dumper(config *configs.Config) {
5153
"rom to the VM along with the card in order to get a functional passthrough.\n",
5254
"In many cases you can find your vbios at https://www.techpowerup.com/vgabios/\n",
5355
"\n",
54-
"You can also attempt to dump your own vbios from TTY using the script in\n",
56+
"If we found a romfile for your GPU you can also attempt to dump your own vbios from TTY using the script in\n",
5557
fmt.Sprintf("%s/utils/dump_vbios.sh\n", scriptdir),
5658
"\n",
5759
)

0 commit comments

Comments
 (0)