bus_managers/firewire: Fix array index out of bounds

if found = 3 at line 200, gFirewire_softc[] index is out of bounds
at line 193, and may be at line 243.
Pointed out by cppcheck.

Change-Id: I0568c503e6edea8f78e0da402271b669ba786def
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3502
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Murai Takashi
2020-12-15 12:02:19 +00:00
committed by Adrien Destugues
parent ebe6011c58
commit 7dec2bff46
@@ -190,6 +190,7 @@ fw_module_init(void)
} }
memset(fw_sc, 0, sizeof(struct firewire_softc)); memset(fw_sc, 0, sizeof(struct firewire_softc));
gFirewire_softc[found] = fw_sc; gFirewire_softc[found] = fw_sc;
if (found < MAX_CARDS - 1)
gFirewire_softc[found + 1] = NULL; gFirewire_softc[found + 1] = NULL;
found++; found++;
@@ -240,7 +241,7 @@ fw_module_uninit(void)
terminate_timer(); terminate_timer();
for (i = 0; gFirewire_softc[i] != NULL; i++) { for (i = 0; i < MAX_CARDS && gFirewire_softc[i] != NULL; i++) {
fwohci_pci_detach(i); fwohci_pci_detach(i);
free(gFirewire_softc[i]); free(gFirewire_softc[i]);
free(gFwohci_softc[i]); free(gFwohci_softc[i]);