hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/net/wireless/marvell/mwifiex/pcie.c
....@@ -183,7 +183,7 @@
183183 .can_ext_scan = true,
184184 };
185185
186
-static const struct of_device_id mwifiex_pcie_of_match_table[] = {
186
+static const struct of_device_id mwifiex_pcie_of_match_table[] __maybe_unused = {
187187 { .compatible = "pci11ab,2b42" },
188188 { .compatible = "pci1b4b,2b42" },
189189 { }
....@@ -200,6 +200,8 @@
200200 }
201201
202202 static void mwifiex_pcie_work(struct work_struct *work);
203
+static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter);
204
+static int mwifiex_pcie_delete_evtbd_ring(struct mwifiex_adapter *adapter);
203205
204206 static int
205207 mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb,
....@@ -794,14 +796,15 @@
794796 if (!skb) {
795797 mwifiex_dbg(adapter, ERROR,
796798 "Unable to allocate skb for RX ring.\n");
797
- kfree(card->rxbd_ring_vbase);
798799 return -ENOMEM;
799800 }
800801
801802 if (mwifiex_map_pci_memory(adapter, skb,
802803 MWIFIEX_RX_DATA_BUF_SIZE,
803
- DMA_FROM_DEVICE))
804
- return -1;
804
+ DMA_FROM_DEVICE)) {
805
+ kfree_skb(skb);
806
+ return -ENOMEM;
807
+ }
805808
806809 buf_pa = MWIFIEX_SKB_DMA_ADDR(skb);
807810
....@@ -851,7 +854,6 @@
851854 if (!skb) {
852855 mwifiex_dbg(adapter, ERROR,
853856 "Unable to allocate skb for EVENT buf.\n");
854
- kfree(card->evtbd_ring_vbase);
855857 return -ENOMEM;
856858 }
857859 skb_put(skb, MAX_EVENT_SIZE);
....@@ -859,8 +861,7 @@
859861 if (mwifiex_map_pci_memory(adapter, skb, MAX_EVENT_SIZE,
860862 DMA_FROM_DEVICE)) {
861863 kfree_skb(skb);
862
- kfree(card->evtbd_ring_vbase);
863
- return -1;
864
+ return -ENOMEM;
864865 }
865866
866867 buf_pa = MWIFIEX_SKB_DMA_ADDR(skb);
....@@ -1060,6 +1061,7 @@
10601061 */
10611062 static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter)
10621063 {
1064
+ int ret;
10631065 struct pcie_service_card *card = adapter->card;
10641066 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
10651067
....@@ -1098,7 +1100,10 @@
10981100 (u32)((u64)card->rxbd_ring_pbase >> 32),
10991101 card->rxbd_ring_size);
11001102
1101
- return mwifiex_init_rxq_ring(adapter);
1103
+ ret = mwifiex_init_rxq_ring(adapter);
1104
+ if (ret)
1105
+ mwifiex_pcie_delete_rxbd_ring(adapter);
1106
+ return ret;
11021107 }
11031108
11041109 /*
....@@ -1129,6 +1134,7 @@
11291134 */
11301135 static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter)
11311136 {
1137
+ int ret;
11321138 struct pcie_service_card *card = adapter->card;
11331139 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg;
11341140
....@@ -1163,7 +1169,10 @@
11631169 (u32)((u64)card->evtbd_ring_pbase >> 32),
11641170 card->evtbd_ring_size);
11651171
1166
- return mwifiex_pcie_init_evt_ring(adapter);
1172
+ ret = mwifiex_pcie_init_evt_ring(adapter);
1173
+ if (ret)
1174
+ mwifiex_pcie_delete_evtbd_ring(adapter);
1175
+ return ret;
11671176 }
11681177
11691178 /*