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 <pulkomandy@gmail.com>
This commit is contained in:
Murai Takashi 2020-12-13 20:36:29 +09:00 committed by Adrien Destugues
parent ebe6011c58
commit 7dec2bff46

View File

@ -190,7 +190,8 @@ fw_module_init(void)
}
memset(fw_sc, 0, sizeof(struct firewire_softc));
gFirewire_softc[found] = fw_sc;
gFirewire_softc[found+1] = NULL;
if (found < MAX_CARDS - 1)
gFirewire_softc[found + 1] = NULL;
found++;
info = (pci_info*)malloc(sizeof(pci_info));
@ -240,7 +241,7 @@ fw_module_uninit(void)
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);
free(gFirewire_softc[i]);
free(gFwohci_softc[i]);