352-v5.4-0001-Revert-brcmfmac-fix-NULL-pointer-derefence-during-US.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. From a84a60ccdd65278485fb495f468a5ab91a75c649 Mon Sep 17 00:00:00 2001
  2. From: Arend van Spriel <arend.vanspriel@broadcom.com>
  3. Date: Thu, 11 Jul 2019 11:05:06 +0200
  4. Subject: [PATCH] Revert "brcmfmac: fix NULL pointer derefence during USB
  5. disconnect"
  6. This reverts commit 5cdb0ef6144f47440850553579aa923c20a63f23. Subsequent
  7. changes make rework the driver code fixing the issue differently.
  8. Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  9. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  10. ---
  11. .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c | 11 ++---------
  12. .../wireless/broadcom/brcm80211/brcmfmac/bcdc.h | 6 ++----
  13. .../wireless/broadcom/brcm80211/brcmfmac/core.c | 4 +---
  14. .../broadcom/brcm80211/brcmfmac/fwsignal.c | 16 ++++------------
  15. .../broadcom/brcm80211/brcmfmac/fwsignal.h | 3 +--
  16. .../wireless/broadcom/brcm80211/brcmfmac/proto.c | 10 ++--------
  17. .../wireless/broadcom/brcm80211/brcmfmac/proto.h | 3 +--
  18. 7 files changed, 13 insertions(+), 40 deletions(-)
  19. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
  20. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
  21. @@ -479,18 +479,11 @@ fail:
  22. return -ENOMEM;
  23. }
  24. -void brcmf_proto_bcdc_detach_pre_delif(struct brcmf_pub *drvr)
  25. -{
  26. - struct brcmf_bcdc *bcdc = drvr->proto->pd;
  27. -
  28. - brcmf_fws_detach_pre_delif(bcdc->fws);
  29. -}
  30. -
  31. -void brcmf_proto_bcdc_detach_post_delif(struct brcmf_pub *drvr)
  32. +void brcmf_proto_bcdc_detach(struct brcmf_pub *drvr)
  33. {
  34. struct brcmf_bcdc *bcdc = drvr->proto->pd;
  35. drvr->proto->pd = NULL;
  36. - brcmf_fws_detach_post_delif(bcdc->fws);
  37. + brcmf_fws_detach(bcdc->fws);
  38. kfree(bcdc);
  39. }
  40. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.h
  41. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.h
  42. @@ -18,16 +18,14 @@
  43. #ifdef CPTCFG_BRCMFMAC_PROTO_BCDC
  44. int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr);
  45. -void brcmf_proto_bcdc_detach_pre_delif(struct brcmf_pub *drvr);
  46. -void brcmf_proto_bcdc_detach_post_delif(struct brcmf_pub *drvr);
  47. +void brcmf_proto_bcdc_detach(struct brcmf_pub *drvr);
  48. void brcmf_proto_bcdc_txflowblock(struct device *dev, bool state);
  49. void brcmf_proto_bcdc_txcomplete(struct device *dev, struct sk_buff *txp,
  50. bool success);
  51. struct brcmf_fws_info *drvr_to_fws(struct brcmf_pub *drvr);
  52. #else
  53. static inline int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr) { return 0; }
  54. -static void brcmf_proto_bcdc_detach_pre_delif(struct brcmf_pub *drvr) {};
  55. -static inline void brcmf_proto_bcdc_detach_post_delif(struct brcmf_pub *drvr) {}
  56. +static inline void brcmf_proto_bcdc_detach(struct brcmf_pub *drvr) {}
  57. #endif
  58. #endif /* BRCMFMAC_BCDC_H */
  59. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  60. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  61. @@ -1294,8 +1294,6 @@ void brcmf_detach(struct device *dev)
  62. brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN);
  63. - brcmf_proto_detach_pre_delif(drvr);
  64. -
  65. /* make sure primary interface removed last */
  66. for (i = BRCMF_MAX_IFS-1; i > -1; i--)
  67. brcmf_remove_interface(drvr->iflist[i], false);
  68. @@ -1305,7 +1303,7 @@ void brcmf_detach(struct device *dev)
  69. brcmf_bus_stop(drvr->bus_if);
  70. - brcmf_proto_detach_post_delif(drvr);
  71. + brcmf_proto_detach(drvr);
  72. brcmf_debug_detach(drvr);
  73. bus_if->drvr = NULL;
  74. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
  75. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
  76. @@ -2420,25 +2420,17 @@ struct brcmf_fws_info *brcmf_fws_attach(
  77. return fws;
  78. fail:
  79. - brcmf_fws_detach_pre_delif(fws);
  80. - brcmf_fws_detach_post_delif(fws);
  81. + brcmf_fws_detach(fws);
  82. return ERR_PTR(rc);
  83. }
  84. -void brcmf_fws_detach_pre_delif(struct brcmf_fws_info *fws)
  85. +void brcmf_fws_detach(struct brcmf_fws_info *fws)
  86. {
  87. if (!fws)
  88. return;
  89. - if (fws->fws_wq) {
  90. - destroy_workqueue(fws->fws_wq);
  91. - fws->fws_wq = NULL;
  92. - }
  93. -}
  94. -void brcmf_fws_detach_post_delif(struct brcmf_fws_info *fws)
  95. -{
  96. - if (!fws)
  97. - return;
  98. + if (fws->fws_wq)
  99. + destroy_workqueue(fws->fws_wq);
  100. /* cleanup */
  101. brcmf_fws_lock(fws);
  102. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
  103. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
  104. @@ -19,8 +19,7 @@
  105. #define FWSIGNAL_H_
  106. struct brcmf_fws_info *brcmf_fws_attach(struct brcmf_pub *drvr);
  107. -void brcmf_fws_detach_pre_delif(struct brcmf_fws_info *fws);
  108. -void brcmf_fws_detach_post_delif(struct brcmf_fws_info *fws);
  109. +void brcmf_fws_detach(struct brcmf_fws_info *fws);
  110. bool brcmf_fws_queue_skbs(struct brcmf_fws_info *fws);
  111. bool brcmf_fws_fc_active(struct brcmf_fws_info *fws);
  112. void brcmf_fws_hdrpull(struct brcmf_if *ifp, s16 siglen, struct sk_buff *skb);
  113. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
  114. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
  115. @@ -66,22 +66,16 @@ fail:
  116. return -ENOMEM;
  117. }
  118. -void brcmf_proto_detach_post_delif(struct brcmf_pub *drvr)
  119. +void brcmf_proto_detach(struct brcmf_pub *drvr)
  120. {
  121. brcmf_dbg(TRACE, "Enter\n");
  122. if (drvr->proto) {
  123. if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)
  124. - brcmf_proto_bcdc_detach_post_delif(drvr);
  125. + brcmf_proto_bcdc_detach(drvr);
  126. else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF)
  127. brcmf_proto_msgbuf_detach(drvr);
  128. kfree(drvr->proto);
  129. drvr->proto = NULL;
  130. }
  131. }
  132. -
  133. -void brcmf_proto_detach_pre_delif(struct brcmf_pub *drvr)
  134. -{
  135. - if (drvr->proto && drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)
  136. - brcmf_proto_bcdc_detach_pre_delif(drvr);
  137. -}
  138. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
  139. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
  140. @@ -53,8 +53,7 @@ struct brcmf_proto {
  141. int brcmf_proto_attach(struct brcmf_pub *drvr);
  142. -void brcmf_proto_detach_pre_delif(struct brcmf_pub *drvr);
  143. -void brcmf_proto_detach_post_delif(struct brcmf_pub *drvr);
  144. +void brcmf_proto_detach(struct brcmf_pub *drvr);
  145. static inline int brcmf_proto_hdrpull(struct brcmf_pub *drvr, bool do_fws,
  146. struct sk_buff *skb,