hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hid/intel-ish-hid/ishtp/dma-if.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * ISHTP DMA I/F functions
34 *
45 * Copyright (c) 2003-2016, Intel Corporation.
5
- *
6
- * This program is free software; you can redistribute it and/or modify it
7
- * under the terms and conditions of the GNU General Public License,
8
- * version 2, as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope it will be useful, but WITHOUT
11
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13
- * more details.
14
- *
156 */
167
178 #include <linux/slab.h>
....@@ -113,6 +104,11 @@
113104 int required_slots = (size / DMA_SLOT_SIZE)
114105 + 1 * (size % DMA_SLOT_SIZE != 0);
115106
107
+ if (!dev->ishtp_dma_tx_map) {
108
+ dev_err(dev->devc, "Fail to allocate Tx map\n");
109
+ return NULL;
110
+ }
111
+
116112 spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
117113 for (i = 0; i <= (dev->ishtp_dma_num_slots - required_slots); i++) {
118114 free = 1;
....@@ -159,6 +155,11 @@
159155 return;
160156 }
161157
158
+ if (!dev->ishtp_dma_tx_map) {
159
+ dev_err(dev->devc, "Fail to allocate Tx map\n");
160
+ return;
161
+ }
162
+
162163 i = (msg_addr - dev->ishtp_host_dma_tx_buf) / DMA_SLOT_SIZE;
163164 spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags);
164165 for (j = 0; j < acked_slots; j++) {