Check some of the previously unchecked error cases when loading firmware. This
makes it abort earlier when no firmware files are available. Note that this worked some time ago and seems to be an edge case triggering an issue in the slab allocator. Freeing the buffer (possibly allocated with an invalid size) in the error case triggered the assert in #6679. That should probably be looked at, but meanwhile this should close #6679. Note also that looking for firmware is deliberatly done only at open() time, since the configured operational mode determines the firmware to be used and having the firmware loaded later makes the mode easily changeable at runtime. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41144 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
2e43bcca24
commit
8c28e64bcd
@ -1179,10 +1179,24 @@ IPW2100::LoadMicrocodeAndFirmware()
|
||||
|
||||
TRACE_ALWAYS(("IPW2100: loading firmware %s\n", firmware));
|
||||
int fd = open(firmware, B_READ_ONLY);
|
||||
if (fd < 0) {
|
||||
TRACE_ALWAYS(("IPW2100: firmware file unavailable\n"));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
int32 fileSize = lseek(fd, 0, SEEK_END);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
if (fileSize <= 0) {
|
||||
TRACE_ALWAYS(("IPW2100: firmware file seems empty\n"));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
uint8 *buffer = (uint8 *)malloc(fileSize);
|
||||
if (buffer == NULL) {
|
||||
TRACE_ALWAYS(("IPW2100: no memory for firmware buffer\n"));
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
ssize_t readCount = read(fd, buffer, fileSize);
|
||||
TRACE(("IPW2100: read %ld bytes\n", readCount));
|
||||
close(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user