If an application specifies zero-copy read-buffers to read the data into
for a read10 call, the application might have specified too few buffers for the full I/O. For example if the application tries to read just 512 bytes off a MMC device. In this case we wopuld run out of buffers and fail with a SEGV. Instead of failing like this, return NULL from the function to locate a suitable buffer and read the remaining data from the command into the callback buffer instead, just like when no read-buffer at all has been specified.
This commit is contained in:
@@ -1107,8 +1107,14 @@ scsi_task_get_data_in_buffer(struct scsi_task *task, uint32_t pos, ssize_t *coun
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (pos >= sdb->len) {
|
while (pos >= sdb->len) {
|
||||||
pos -= sdb->len;
|
pos -= sdb->len;
|
||||||
sdb = sdb->next;
|
sdb = sdb->next;
|
||||||
|
if (sdb == NULL) {
|
||||||
|
/* someone issued a read but did not provide enough user buffers for all the data.
|
||||||
|
* maybe someone tried to read just 512 bytes off a MMC device?
|
||||||
|
*/
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count && *count > sdb->len - pos) {
|
if (count && *count > sdb->len - pos) {
|
||||||
|
|||||||
Reference in New Issue
Block a user