.. | .. |
---|
22 | 22 | #include "osdep_intf.h" |
---|
23 | 23 | #include "usb_ops.h" |
---|
24 | 24 | |
---|
| 25 | +#include <linux/usb.h> |
---|
| 26 | +#include <linux/ieee80211.h> |
---|
25 | 27 | |
---|
26 | 28 | static const u8 P802_1H_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0xf8}; |
---|
27 | 29 | static const u8 RFC1042_OUI[P80211_OUI_LEN] = {0x00, 0x00, 0x00}; |
---|
.. | .. |
---|
55 | 57 | sint i; |
---|
56 | 58 | struct xmit_buf *pxmitbuf; |
---|
57 | 59 | struct xmit_frame *pxframe; |
---|
| 60 | + int j; |
---|
58 | 61 | |
---|
59 | 62 | memset((unsigned char *)pxmitpriv, 0, sizeof(struct xmit_priv)); |
---|
60 | 63 | spin_lock_init(&pxmitpriv->lock); |
---|
.. | .. |
---|
117 | 120 | _init_queue(&pxmitpriv->pending_xmitbuf_queue); |
---|
118 | 121 | pxmitpriv->pallocated_xmitbuf = |
---|
119 | 122 | 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; |
---|
125 | 125 | pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - |
---|
126 | 126 | ((addr_t)(pxmitpriv->pallocated_xmitbuf) & 3); |
---|
127 | 127 | pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; |
---|
.. | .. |
---|
129 | 129 | INIT_LIST_HEAD(&pxmitbuf->list); |
---|
130 | 130 | pxmitbuf->pallocated_buf = |
---|
131 | 131 | 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 | + } |
---|
134 | 136 | pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ - |
---|
135 | 137 | ((addr_t) (pxmitbuf->pallocated_buf) & |
---|
136 | 138 | (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 | + } |
---|
139 | 143 | list_add_tail(&pxmitbuf->list, |
---|
140 | 144 | &(pxmitpriv->free_xmitbuf_queue.queue)); |
---|
141 | 145 | pxmitbuf++; |
---|
.. | .. |
---|
146 | 150 | init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); |
---|
147 | 151 | tasklet_setup(&pxmitpriv->xmit_tasklet, r8712_xmit_bh); |
---|
148 | 152 | 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; |
---|
149 | 175 | } |
---|
150 | 176 | |
---|
151 | 177 | void _free_xmit_priv(struct xmit_priv *pxmitpriv) |
---|
.. | .. |
---|
709 | 735 | break; |
---|
710 | 736 | case AUTO_VCS: |
---|
711 | 737 | 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); |
---|
713 | 739 | if (!perp) { |
---|
714 | 740 | pxmitpriv->vcs = NONE_VCS; |
---|
715 | 741 | } else { |
---|