The rtl8189 and similar drivers are not compatible with commit mac80211: rebase ontop of v4.18.5 and newer

I've updated the kernel from 4.14.66 to 4.14.76 and rebuilt all from source to update the rest of the system at the same time.
When tried to connect the WiFi client, the router reboots with the following serial dump:

[  881.829112] ------------[ cut here ]------------
[  881.833746] kernel BUG at mm/slub.c:3892!
[  881.837751] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
[  881.843574] Modules linked in: pppoe ppp_async pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_FLOWOFFLOAD usbnet slhc r8152 nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack iptable_mangle iptable_filter ip_tables crc_ccitt 8189es cfg80211 compat rtc_sunxi ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables x_tables
[  881.901624] CPU: 0 PID: 2770 Comm: RTW_CMD_THREAD Not tainted 4.14.76 #0
[  881.908313] Hardware name: Allwinner sun8i Family
[  881.913011] task: cec79f80 task.stack: ce8d8000
[  881.917544] PC is at kfree+0x68/0x190
[  881.921277] LR is at nl80211_update_connect_params+0xf08/0xf98 [cfg80211]
[  881.928055] pc : [<c02fc928>]    lr : [<bf068e78>]    psr: 40000013
[  881.934311] sp : ce8d9dc8  ip : 00000000  fp : cf288164
[  881.939528] r10: d0ad8654  r9 : cf288030  r8 : 00000000
[  881.944737] r7 : ce8d9e70  r6 : ce8d9e08  r5 : cf8dad80  r4 : cffb4b00
[  881.951255] r3 : 00000000  r2 : c0c87840  r1 : cf8da2cb  r0 : d0ad80d4
[  881.957773] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  881.964898] Control: 30c5387d  Table: 4f3c7a00  DAC: fffffffd
[  881.970636] Process RTW_CMD_THREAD (pid: 2770, stack limit = 0xce8d8210)
[  881.977327] Stack: (0xce8d9dc8 to 0xce8da000)
[  881.981681] 9dc0:                   ce8d9e08 ce8d9e70 cf288014 cf8dad80 ce8d9e08 ce8d9e70
[  881.989849] 9de0: 00000000 bf068e78 00000005 00000013 cf288014 00000000 cf8dad80 cf288034
[  881.998017] 9e00: cf288030 00000000 d0ad8668 00000000 00000000 cf3f4800 01080020 cf26a000
[  882.006185] 9e20: cf8da24a ce8d9e70 00000000 cf8dad80 0000e346 bf069084 00000000 cf26a000
[  882.014353] 9e40: cf3f4800 cf8da24a ce8d9e70 cfb30c00 00000000 00000000 0000008b cf8da240
[  882.022521] 9e60: ce8d8000 ceedc200 d0a7f510 bf0e6410 00000000 00000000 ceedc200 d0a7f510
[  882.030688] 9e80: 0000e346 bf10b6f8 04840801 fffffffc 04840801 00000000 00000000 d0a7e000
[  882.038856] 9ea0: 00000484 bf0a1b6c ce8d9f04 d0a83000 d0a7e000 00000000 00000000 bf1076b4
[  882.047024] 9ec0: 00000000 bf0ee808 d0ad823b d0ad80d4 d0a7e000 00000000 cf8da25c 0000006f
[  882.055191] 9ee0: 00000000 bf0ee9d0 ce8d9f04 00000000 d0ad80d4 bf0c1d34 d0a7e000 c02fd4c8
[  882.063359] 9f00: d0a7e000 0000008b d0a7e000 d0ad80d4 d0a7e000 d0ad80d4 0000008b cf8da240
[  882.071527] 9f20: d0a7e000 d0a7e000 d0ad80d4 bf0a790c ceedc200 bf14302c d0a7e000 d0a7f500
[  882.079695] 9f40: ce8d8000 bf0b6340 ce88bf00 d0a7e000 d0a7f520 bf097948 ce93b6dc d0a7f54c
[  882.087863] 9f60: bf09774c ce93b6c0 ce8d8000 cf8d1e00 00000000 ce93b6dc d0a7e000 bf09774c
[  882.096030] 9f80: ce46fc0c c024c3b0 00000000 cf8d1e00 c024c284 00000000 00000000 00000000
[  882.104197] 9fa0: 00000000 00000000 00000000 c02211d8 00000000 00000000 00000000 00000000
[  882.112364] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  882.120531] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
[  882.128732] [<c02fc928>] (kfree) from [<bf068e78>] (nl80211_update_connect_params+0xf08/0xf98 [cfg80211])
[  882.138335] [<bf068e78>] (nl80211_update_connect_params [cfg80211]) from [<bf069084>] (cfg80211_new_sta+0x74/0x104 [cfg80211])
[  882.150026] [<bf069084>] (cfg80211_new_sta [cfg80211]) from [<bf0e6410>] (rtw_cfg80211_indicate_sta_assoc+0x5c/0x64 [8189es])
[  882.161512] [<bf0e6410>] (rtw_cfg80211_indicate_sta_assoc [8189es]) from [<bf0a790c>] (rtw_stassoc_event_callback+0xec/0x1e4 [8189es])
[  882.173760] [<bf0a790c>] (rtw_stassoc_event_callback [8189es]) from [<bf0b6340>] (mlme_evt_hdl+0x78/0x90 [8189es])
[  882.184267] [<bf0b6340>] (mlme_evt_hdl [8189es]) from [<bf097948>] (rtw_cmd_thread+0x1fc/0x340 [8189es])
[  882.193826] [<bf097948>] (rtw_cmd_thread [8189es]) from [<c024c3b0>] (kthread+0x12c/0x138)
[  882.202085] [<c024c3b0>] (kthread) from [<c02211d8>] (ret_from_fork+0x14/0x3c)
[  882.209301] Code: 1a000003 e5943014 e3130001 1a000000 (e7f001f2) 

I've never hit such a failure and I'm not as skilled in the kernel errors to solve it, please be so kind and help.

Some more relevant information:
Board is OrangePi R1 board and I used the rtl8189es.patch from here:;a=commit;h=46b6c11e5263e00397ac756173d517ea70bdb207
to bring the on-board wifi to work.

For fresh installation I've used this source code:;a=commit;h=0d0bd8e6da9d93d8b8ae6a936d564fbeb39c6f77

made the following modification in the /package/kernel/mac80211/files/lib/netifd/wireless/ :

mac80211_interface_cleanup() {
	local phy="$1"

	for wdev in $(list_phy_interfaces "$phy"); do
		ip link set dev "$wdev" down 2>/dev/null
#		iw dev "$wdev" del

and used the following steps for build:

patch -p1 -i rtl8189es.patch
make package/symlinks
make menuconfig
make -j4

When finished, I've put img on the SD and booted the OPi R1 board.
Used the minimal setup to create wpa2 AP with passwd.

The same steps I've already used for kernels 4.14.25, 41, 54 and 66 and it worked.

Can you confirm you're running OpenWrt?

Surely yes:

Model Xunlong Orange Pi R1
Architecture ARMv7 Processor rev 5 (v7l)
Firmware Version OpenWrt-18.06.01-e9d92bf-2018/09/26 / LuCI Master (git-19.038.66435-4e5111e)
Kernel Version 4.14.72

This is the latest working version, update to kernel 4.14.73 causes the kernel panic as described above.

The same kernel issue is with the Orange Pi Zero Plus (H5) board and kernel 4.14.95.
The WiFi rtl8189fs.patch was used.
When try to connect, it hangs, not reboots like with H3 board.

Also on 4.19? It does look like a wifi driver bug however...

@hauke Got it. The rtl8189 driver is not compatible with the new mac80211 version from this commit:;a=commit;h=d9eefa7a7031543571d434693c7f984dfbdc990d
And all other newer versions are not compatible too.
Please provide the compatibility patch.

Does someone followed up on this ? i have helped package a rtl8821cu driver which shows in OpenWrt ( i built the master branch with a kernel 5.4 ) but it misses the relevant iwinfo support to have it used as an AP

No specific iwinfo support is needed, but native nl80211 support is required for hostapd to work. Furthermore device, firmware and driver must signal the appropriate feature flags (AP mode, interface combinations, regdom, etc.) to the kernel (and indirectly hostapd, via nl80211), but that's basic driver functionality.

OpenWrt doesn't really need any driver specific knowledge to support a device, all nl80211 based drivers are treated alike (nl80211 is a generic abstraction layer).

Realtek nl80211 is shitty ( hence iwinfo showing only Unknown values and OpenWrt on top of that not seeing it as an AP-capable driver), just found this for reference and will try to build it on my rebased OpenWRT tree ( after adaptation if needed):

Hi , i am also have orange pi r1 board and i am tryin to bring wifi support . I am beginner with openwrt
So i tried your solution but didn't work. When i typed "wifi status" and "modprobe 8189es" in command line there is nothing and i confused about editing
Shall i remove everything in this file and write only code below?

made the following modification in the /package/kernel/mac80211/files/lib/netifd/wireless/ :

mac80211_interface_cleanup() {
	local phy="$1"

	for wdev in $(list_phy_interfaces "$phy"); do
		ip link set dev "$wdev" down 2>/dev/null
#		iw dev "$wdev" del

my kernel version:
Linux OpenWrt 4.14.99 #0 SMP PREEMPT Thu Feb 14 20:43:07 2019 armv7l GNU/Linux

any help would be appreciated

Thank you for your log. I have located the problem and made a commit. Under OpenWrt release 19.07.7, cfg80211 test ok.

PS: I made other unrelated changes to adapt to my device
device: nanopi-r1s-h3
cpu: sun8i-h3
wifi: rtl8189etv
net: rtl8153

you can modify code manually and use "git format-patch -1" to generate a patch. then place the patch to hauke's rtl8189es/patches folder.

refer: abperiasamy/rtl8812AU_8821AU_linux@076ac48
saiarcot895 authored and harshavardhana committed on 11 Jan 2019:

  • Add explicit memset call to avoid potentially corrupt data. (#277)
    In kernel 4.19, I saw a kernel crash where kfree was trying to free
    some garbage pointer. This occurred because this structure wasn't
    explicitly initialized to 0.

Now rtl8189es's ap mode works normally, but client mode still not works.

I can scan other ap, but can't save client mode settings. (Only one of the client and ap modes can be selected by Makefile?)
on older version, once saving client mode settings, client mode works normally. Buf after restarting, wifi can't run.

If you can provide some hints, I can try to fix these problems, but this is likely to be a long-term process. The driver code of realtek is not easy to read.

Someone built it for the master or 21 branch?
Could you share, please. I could not do it, but in this case I am a monkey.
I am interested in orange PI R1 AP mode in the fresh version OpenWrt