drivers/bus/usb: Fix potential memory leak
* Fix potential leak of 'controlData' at line 701, which is allocated at line 695. Pointed out by Clang Static Analyzer. * Add NULL check to 'controlData'. Change-Id: I96b0244d05d303b4c08ac8969f5ce5fc2e5012f9 Reviewed-on: https://review.haiku-os.org/c/1059 Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
c054900882
commit
29dcf8568b
@ -693,11 +693,14 @@ usb_raw_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
|
||||
return B_BUFFER_OVERFLOW;
|
||||
|
||||
void *controlData = malloc(command.control.length);
|
||||
if (controlData == NULL)
|
||||
return B_NO_MEMORY;
|
||||
bool inTransfer = (command.control.request_type
|
||||
& USB_ENDPOINT_ADDR_DIR_IN) != 0;
|
||||
if (!IS_USER_ADDRESS(command.control.data)
|
||||
|| (!inTransfer && user_memcpy(controlData,
|
||||
command.control.data, command.control.length) != B_OK)) {
|
||||
free(controlData);
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user