hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/staging/rtl8712/rtl871x_xmit.c
....@@ -22,6 +22,8 @@
2222 #include "osdep_intf.h"
2323 #include "usb_ops.h"
2424
25
+#include <linux/usb.h>
26
+#include <linux/ieee80211.h>
2527
2628 static const u8 P802_1H_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0xf8};
2729 static const u8 RFC1042_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0x00};
....@@ -55,6 +57,7 @@
5557 sint i;
5658 struct xmit_buf *pxmitbuf;
5759 struct xmit_frame *pxframe;
60
+ int j;
5861
5962 memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv));
6063 spin_lock_init(&pxmitpriv->lock);
....@@ -117,11 +120,8 @@
117120 _init_queue(&pxmitpriv->pending_xmitbuf_queue);
118121 pxmitpriv->pallocated_xmitbuf =
119122 kmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4, GFP_ATOMIC);
120
- if (!pxmitpriv->pallocated_xmitbuf) {
121
- kfree(pxmitpriv->pallocated_frame_buf);
122
- pxmitpriv->pallocated_frame_buf = NULL;
123
- return -ENOMEM;
124
- }
123
+ if (!pxmitpriv->pallocated_xmitbuf)
124
+ goto clean_up_frame_buf;
125125 pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 -
126126 ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3);
127127 pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf;
....@@ -129,13 +129,17 @@
129129 INIT_LIST_HEAD(&pxmitbuf->list);
130130 pxmitbuf->pallocated_buf =
131131 kmalloc(MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ, GFP_ATOMIC);
132
- if (!pxmitbuf->pallocated_buf)
133
- return -ENOMEM;
132
+ if (!pxmitbuf->pallocated_buf) {
133
+ j = 0;
134
+ goto clean_up_alloc_buf;
135
+ }
134136 pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ -
135137 ((addr_t) (pxmitbuf->pallocated_buf) &
136138 (XMITBUF_ALIGN_SZ - 1));
137
- if (r8712_xmit_resource_alloc(padapter, pxmitbuf))
138
- return -ENOMEM;
139
+ if (r8712_xmit_resource_alloc(padapter, pxmitbuf)) {
140
+ j = 1;
141
+ goto clean_up_alloc_buf;
142
+ }
139143 list_add_tail(&pxmitbuf->list,
140144 &(pxmitpriv->free_xmitbuf_queue.queue));
141145 pxmitbuf++;
....@@ -146,6 +150,28 @@
146150 init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry);
147151 tasklet_setup(&pxmitpriv->xmit_tasklet, r8712_xmit_bh);
148152 return 0;
153
+
154
+clean_up_alloc_buf:
155
+ if (j) {
156
+ /* failure happened in r8712_xmit_resource_alloc()
157
+ * delete extra pxmitbuf->pallocated_buf
158
+ */
159
+ kfree(pxmitbuf->pallocated_buf);
160
+ }
161
+ for (j = 0; j < i; j++) {
162
+ int k;
163
+
164
+ pxmitbuf--; /* reset pointer */
165
+ kfree(pxmitbuf->pallocated_buf);
166
+ for (k = 0; k < 8; k++) /* delete xmit urb's */
167
+ usb_free_urb(pxmitbuf->pxmit_urb[k]);
168
+ }
169
+ kfree(pxmitpriv->pallocated_xmitbuf);
170
+ pxmitpriv->pallocated_xmitbuf = NULL;
171
+clean_up_frame_buf:
172
+ kfree(pxmitpriv->pallocated_frame_buf);
173
+ pxmitpriv->pallocated_frame_buf = NULL;
174
+ return -ENOMEM;
149175 }
150176
151177 void _free_xmit_priv(struct xmit_priv *pxmitpriv)
....@@ -709,7 +735,7 @@
709735 break;
710736 case AUTO_VCS:
711737 default:
712
- perp = r8712_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len);
738
+ perp = r8712_get_ie(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len);
713739 if (!perp) {
714740 pxmitpriv->vcs = NONE_VCS;
715741 } else {