diff options
| author | Even Xu <even.xu@intel.com> | 2025-12-26 11:39:53 +0800 |
|---|---|---|
| committer | Benjamin Tissoires <bentiss@kernel.org> | 2026-01-07 15:11:39 +0100 |
| commit | a9a917998d172ec117f9e9de1919174153c0ace4 (patch) | |
| tree | d78da04a294942fc3afdca062d1c7e893bb96c9f /drivers/hid/intel-thc-hid | |
| parent | dd76788f9ec4f33f0f43838cac1304265d944328 (diff) | |
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>
Diffstat (limited to 'drivers/hid/intel-thc-hid')
| -rw-r--r-- | drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c index a0c368aa7979..6ee675e0a738 100644 --- a/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c +++ b/drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c @@ -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) { |
