mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
HID: Intel-thc-hid: Intel-thc: Add safety check for reading DMA buffer
Add DMA buffer readiness check before reading DMA buffer to avoid unexpected NULL pointer accessing. Signed-off-by: Even Xu <even.xu@intel.com> Tested-by: Rui Zhang <rui1.zhang@intel.com> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
This commit is contained in:
committed by
Benjamin Tissoires
parent
dd76788f9e
commit
a9a917998d
@@ -575,6 +575,11 @@ static int read_dma_buffer(struct thc_device *dev,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!read_config->prd_tbls || !read_config->sgls[prd_table_index]) {
|
||||
dev_err_once(dev->dev, "PRD tables are not ready yet\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
prd_tbl = &read_config->prd_tbls[prd_table_index];
|
||||
mes_len = calc_message_len(prd_tbl, &nent);
|
||||
if (mes_len > read_config->max_packet_size) {
|
||||
|
||||
Reference in New Issue
Block a user