HID: Intel-thc-hid: Intel-thc: Add safety check for reading DMA buffer
Subsystems (2)
Even Xu
maintainerPATCH 1/1 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 <[email protected]>
Tested-by Rui Zhang <[email protected]>
--- drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +5 -0
@@ -573,6 +573,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) {
Signature · 1 line
2.40.1
Quoted 4 lines · Even Xu
Add DMA buffer readiness check before reading DMA buffer to avoid unexpected NULL pointer accessing.
Applied to hid/hid.git (for-6.19/upstream-fixes), thanks!
[1/1] HID: Intel-thc-hid: Intel-thc: Add safety check for reading DMA buffer
https://git.kernel.org/hid/hid/c/a9a917998d17
Cheers,
Signature · 1 line
Benjamin Tissoires <[email protected]>