Skip to content

Commit b3d40c3

Browse files
JiangJiasJiri Kosina
authored andcommitted
HID: intel_ish-hid: Add check for ishtp_dma_tx_map
As the kcalloc may return NULL pointer, it should be better to check the ishtp_dma_tx_map before use in order to avoid NULL pointer dereference. Fixes: 3703f53 ("HID: intel_ish-hid: ISH Transport layer") Signed-off-by: Jiasheng Jiang <[email protected]> Acked-by: Srinivas Pandruvada <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 54f27dc commit b3d40c3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/hid/intel-ish-hid/ishtp/dma-if.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ void *ishtp_cl_get_dma_send_buf(struct ishtp_device *dev,
104104
int required_slots = (size / DMA_SLOT_SIZE)
105105
+ 1 * (size % DMA_SLOT_SIZE != 0);
106106

107+
if (!dev->ishtp_dma_tx_map) {
108+
dev_err(dev->devc, "Fail to allocate Tx map\n");
109+
return NULL;
110+
}
111+
107112
spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
108113
for (i = 0; i <= (dev->ishtp_dma_num_slots - required_slots); i++) {
109114
free = 1;
@@ -150,6 +155,11 @@ void ishtp_cl_release_dma_acked_mem(struct ishtp_device *dev,
150155
return;
151156
}
152157

158+
if (!dev->ishtp_dma_tx_map) {
159+
dev_err(dev->devc, "Fail to allocate Tx map\n");
160+
return;
161+
}
162+
153163
i = (msg_addr - dev->ishtp_host_dma_tx_buf) / DMA_SLOT_SIZE;
154164
spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
155165
for (j = 0; j < acked_slots; j++) {

0 commit comments

Comments
 (0)