919-fix-compilation-warning-for-stack-limit.patch 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. --- a/driver/wl_iw.c
  2. +++ b/driver/wl_iw.c
  3. @@ -495,9 +495,9 @@ wl_iw_get_range(
  4. )
  5. {
  6. struct iw_range *range = (struct iw_range *) extra;
  7. - int channels[MAXCHANNEL+1];
  8. - wl_uint32_list_t *list = (wl_uint32_list_t *) channels;
  9. - wl_rateset_t rateset;
  10. + int *channels;
  11. + wl_uint32_list_t *list;
  12. + wl_rateset_t *rateset;
  13. int error, i;
  14. uint sf, ch;
  15. @@ -506,6 +506,17 @@ wl_iw_get_range(
  16. if (!extra)
  17. return -EINVAL;
  18. + channels = kcalloc(MAXCHANNEL+1, sizeof(*channels), GFP_KERNEL);
  19. + if (!channels)
  20. + return -ENOMEM;
  21. + list = (wl_uint32_list_t *) channels;
  22. +
  23. + rateset = kzalloc(sizeof(*rateset), GFP_KERNEL);
  24. + if (!rateset) {
  25. + error = -ENOMEM;
  26. + goto free_channels;
  27. + }
  28. +
  29. dwrq->length = sizeof(struct iw_range);
  30. memset(range, 0, sizeof(range));
  31. @@ -514,8 +525,9 @@ wl_iw_get_range(
  32. /* Set available channels/frequencies */
  33. list->count = htod32(MAXCHANNEL);
  34. - if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, sizeof(channels))))
  35. - return error;
  36. + if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels,
  37. + (MAXCHANNEL+1) * sizeof(*channels))))
  38. + goto free_rateset;
  39. for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) {
  40. range->freq[i].i = dtoh32(list->element[i]);
  41. @@ -549,19 +561,19 @@ wl_iw_get_range(
  42. #endif /* WIRELESS_EXT > 11 */
  43. /* Set available bitrates */
  44. - if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset))))
  45. - return error;
  46. - rateset.count = dtoh32(rateset.count);
  47. - range->num_bitrates = rateset.count;
  48. - for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++)
  49. - range->bitrate[i] = (rateset.rates[i] & 0x7f) * 500000; /* convert to bps */
  50. + if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, rateset, sizeof(*rateset))))
  51. + goto free_rateset;
  52. + rateset->count = dtoh32(rateset->count);
  53. + range->num_bitrates = rateset->count;
  54. + for (i = 0; i < rateset->count && i < IW_MAX_BITRATES; i++)
  55. + range->bitrate[i] = (rateset->rates[i] & 0x7f) * 500000; /* convert to bps */
  56. /* Set an indication of the max TCP throughput
  57. * in bit/s that we can expect using this interface.
  58. * May be use for QoS stuff... Jean II
  59. */
  60. if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i))))
  61. - return error;
  62. + goto free_rateset;
  63. i = dtoh32(i);
  64. if (i == WLC_PHY_TYPE_A)
  65. range->throughput = 24000000; /* 24 Mbits/s */
  66. @@ -624,7 +636,12 @@ wl_iw_get_range(
  67. #endif
  68. #endif /* WIRELESS_EXT > 17 */
  69. - return 0;
  70. +free_rateset:
  71. + kfree(rateset);
  72. +free_channels:
  73. + kfree(channels);
  74. +
  75. + return error;
  76. }
  77. static int
  78. --- a/driver/bcmsrom.c
  79. +++ b/driver/bcmsrom.c
  80. @@ -437,20 +437,37 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  81. uint byteoff, uint nbytes, uint16 *buf)
  82. {
  83. uint i, nw, crc_range;
  84. - uint16 old[SROM_MAXW], new[SROM_MAXW];
  85. + uint16 *old, *new;
  86. uint8 crc;
  87. volatile uint32 val32;
  88. + int rc = 0;
  89. ASSERT(bustype == BUSTYPE(bustype));
  90. + old = MALLOC(osh, SROM_MAXW);
  91. + ASSERT(old != NULL);
  92. + if (!old)
  93. + return -2;
  94. +
  95. + new = MALLOC(osh, SROM_MAXW);
  96. + ASSERT(new != NULL);
  97. + if (!new) {
  98. + rc = -2;
  99. + goto free_old;
  100. + }
  101. +
  102. /* check input - 16-bit access only. use byteoff 0x55aa to indicate
  103. * srclear
  104. */
  105. - if ((byteoff != 0x55aa) && ((byteoff & 1) || (nbytes & 1)))
  106. - return 1;
  107. + if ((byteoff != 0x55aa) && ((byteoff & 1) || (nbytes & 1))) {
  108. + rc = 1;
  109. + goto free_new;
  110. + }
  111. - if ((byteoff != 0x55aa) && ((byteoff + nbytes) > SROM_MAX))
  112. - return 1;
  113. + if ((byteoff != 0x55aa) && ((byteoff + nbytes) > SROM_MAX)) {
  114. + rc = 1;
  115. + goto free_new;
  116. + }
  117. if (BUSTYPE(bustype) == PCMCIA_BUS) {
  118. crc_range = SROM_MAX;
  119. @@ -467,8 +484,10 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  120. nw = crc_range / 2;
  121. /* read first small number words from srom, then adjust the length, read all */
  122. - if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE))
  123. - return 1;
  124. + if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) {
  125. + rc = 1;
  126. + goto free_new;
  127. + }
  128. BS_ERROR(("%s: old[SROM4_SIGN] 0x%x, old[SROM8_SIGN] 0x%x\n",
  129. __FUNCTION__, old[SROM4_SIGN], old[SROM8_SIGN]));
  130. @@ -481,10 +500,13 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  131. __FUNCTION__, buf[SROM4_SIGN], buf[SROM8_SIGN]));
  132. /* block invalid buffer size */
  133. - if (nbytes < SROM4_WORDS * 2)
  134. - return BCME_BUFTOOSHORT;
  135. - else if (nbytes > SROM4_WORDS * 2)
  136. - return BCME_BUFTOOLONG;
  137. + if (nbytes < SROM4_WORDS * 2) {
  138. + rc = BCME_BUFTOOSHORT;
  139. + goto free_new;
  140. + } else if (nbytes > SROM4_WORDS * 2) {
  141. + rc = BCME_BUFTOOLONG;
  142. + goto free_new;
  143. + }
  144. nw = SROM4_WORDS;
  145. } else if (nbytes == SROM_WORDS * 2){ /* the other possible SROM format */
  146. @@ -493,17 +515,22 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  147. nw = SROM_WORDS;
  148. } else {
  149. BS_ERROR(("%s: Invalid input file signature\n", __FUNCTION__));
  150. - return BCME_BADARG;
  151. + rc = BCME_BADARG;
  152. + goto free_new;
  153. }
  154. crc_range = nw * 2;
  155. - if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE))
  156. - return 1;
  157. + if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) {
  158. + rc = 1;
  159. + goto free_new;
  160. + }
  161. } else if ((old[SROM4_SIGN] == SROM4_SIGNATURE) ||
  162. (old[SROM8_SIGN] == SROM4_SIGNATURE)) {
  163. nw = SROM4_WORDS;
  164. crc_range = nw * 2;
  165. - if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE))
  166. - return 1;
  167. + if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) {
  168. + rc = 1;
  169. + goto free_new;
  170. + }
  171. } else {
  172. /* Assert that we have already read enough for sromrev 2 */
  173. ASSERT(crc_range >= SROM_WORDS * 2);
  174. @@ -562,8 +589,10 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  175. }
  176. } else if (BUSTYPE(bustype) == PCMCIA_BUS) {
  177. /* enable writes to the SPROM */
  178. - if (sprom_cmd_pcmcia(osh, SROM_WEN))
  179. - return 1;
  180. + if (sprom_cmd_pcmcia(osh, SROM_WEN)) {
  181. + rc = 1;
  182. + goto free_new;
  183. + }
  184. bcm_mdelay(WRITE_ENABLE_DELAY);
  185. /* write srom */
  186. for (i = 0; i < nw; i++) {
  187. @@ -573,14 +602,15 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  188. }
  189. }
  190. /* disable writes to the SPROM */
  191. - if (sprom_cmd_pcmcia(osh, SROM_WDS))
  192. - return 1;
  193. + if (sprom_cmd_pcmcia(osh, SROM_WDS)) {
  194. + rc = 1;
  195. + goto free_new;
  196. + }
  197. } else if (BUSTYPE(bustype) == SI_BUS) {
  198. #if defined(BCMUSBDEV)
  199. if (SPROMBUS == PCMCIA_BUS) {
  200. uint origidx;
  201. void *regs;
  202. - int rc;
  203. bool wasup;
  204. origidx = si_coreidx(sih);
  205. @@ -596,16 +626,24 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh,
  206. si_core_disable(sih, 0);
  207. si_setcoreidx(sih, origidx);
  208. - return rc;
  209. + goto free_new;
  210. }
  211. #endif
  212. - return 1;
  213. + rc = 1;
  214. + goto free_new;
  215. } else {
  216. - return 1;
  217. + rc = 1;
  218. + goto free_new;
  219. }
  220. bcm_mdelay(WRITE_ENABLE_DELAY);
  221. - return 0;
  222. + rc = 0;
  223. +
  224. +free_new:
  225. + MFREE(osh, new, SROM_MAXW);
  226. +free_old:
  227. + MFREE(osh, old, SROM_MAXW);
  228. + return rc;
  229. }
  230. #if defined(BCMUSBDEV)
  231. --- a/driver/linux_osl.c
  232. +++ b/driver/linux_osl.c
  233. @@ -600,20 +600,29 @@ int
  234. osl_printf(const char *format, ...)
  235. {
  236. va_list args;
  237. - char buf[1024];
  238. + char *buf;
  239. int len;
  240. + buf = kcalloc(1024, sizeof(*buf), GFP_KERNEL);
  241. + if (!buf)
  242. + return (-ENOMEM);
  243. +
  244. /* sprintf into a local buffer because there *is* no "vprintk()".. */
  245. va_start(args, format);
  246. len = vsnprintf(buf, 1024, format, args);
  247. va_end(args);
  248. - if (len > sizeof(buf)) {
  249. + if (len > (sizeof(*buf) * 1024)) {
  250. printk("osl_printf: buffer overrun\n");
  251. - return (0);
  252. + goto exit;
  253. }
  254. - return (printk(buf));
  255. + printk(buf);
  256. +
  257. +exit:
  258. + kfree(buf);
  259. +
  260. + return (0);
  261. }
  262. int
  263. --- a/driver/bcmutils.c
  264. +++ b/driver/bcmutils.c
  265. @@ -13,6 +13,7 @@
  266. #include <typedefs.h>
  267. #include <bcmdefs.h>
  268. +#define __need___va_list
  269. #include <stdarg.h>
  270. #include <bcmutils.h>
  271. #ifdef BCMDRIVER