Re: [PATCH net v2] net: dsa: Check existence of .port_mdb_add callback before calling it

2019-08-06 Thread Vivien Didelot
Hi Chen-Yu,

On Wed, 7 Aug 2019 11:18:28 +0800, Chen-Yu Tsai  wrote:
> On Wed, Aug 7, 2019 at 4:34 AM Vivien Didelot  
> wrote:
> >
> > Hi Chen-Yu,
> >
> > On Wed, 7 Aug 2019 01:49:37 +0800, Chen-Yu Tsai  wrote:
> > > On Wed, Aug 7, 2019 at 1:15 AM Vivien Didelot  
> > > wrote:
> > > >
> > > > Hi Chen-Yu,
> > > >
> > > > On Tue,  6 Aug 2019 15:53:25 +0800, Chen-Yu Tsai  
> > > > wrote:
> > > > > From: Chen-Yu Tsai 
> > > > >
> > > > > With the recent addition of commit 75dad2520fc3 ("net: dsa: b53: 
> > > > > Disable
> > > > > all ports on setup"), users of b53 (BCM53125 on Lamobo R1 in my case)
> > > > > are forced to use the dsa subsystem to enable the switch, instead of
> > > > > having it in the default transparent "forward-to-all" mode.
> > > > >
> > > > > The b53 driver does not support mdb bitmap functions. However the dsa
> > > > > layer does not check for the existence of the .port_mdb_add callback
> > > > > before actually using it. This results in a NULL pointer dereference,
> > > > > as shown in the kernel oops below.
> > > > >
> > > > > The other functions seem to be properly guarded. Do the same for
> > > > > .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.
> > > > >
> > > > > b53 is not the only driver that doesn't support mdb bitmap functions.
> > > > > Others include bcm_sf2, dsa_loop, lantiq_gswip, mt7530, mv88e6060,
> > > > > qca8k, realtek-smi, and vitesse-vsc73xx.
> > > >
> > > > I don't know what you mean by that, there's no "mdb bitmap function"
> > > > support for drivers, only the port_mdb_{prepare,add,del} callbacks...
> > >
> > > The term was coined from commit e6db98db8a95 ("net: dsa: add switch mdb
> > > bitmap functions"). But yeah, .port_mdb_* ops/callbacks would be more
> > > appropriate.
> > >
> > > > > 8<--- cut here ---
> > > > > Unable to handle kernel NULL pointer dereference at virtual 
> > > > > address 
> > > > > pgd = (ptrval)
> > > > > [] *pgd=
> > > > > Internal error: Oops: 8005 [#1] SMP ARM
> > > > > Modules linked in: rtl8xxxu rtl8192cu rtl_usb rtl8192c_common 
> > > > > rtlwifi mac80211 cfg80211
> > > > > CPU: 1 PID: 134 Comm: kworker/1:2 Not tainted 
> > > > > 5.3.0-rc1-00247-gd3519030752a #1
> > > > > Hardware name: Allwinner sun7i (A20) Family
> > > > > Workqueue: events switchdev_deferred_process_work
> > > > > PC is at 0x0
> > > > > LR is at dsa_switch_event+0x570/0x620
> > > > > pc : [<>]lr : []psr: 80070013
> > > > > sp : ee871db8  ip :   fp : ee98d0a4
> > > > > r10: 000c  r9 : 0008  r8 : ee89f710
> > > > > r7 : ee98d040  r6 : ee98d088  r5 : c0f04c48  r4 : ee98d04c
> > > > > r3 :   r2 : ee89f710  r1 : 0008  r0 : ee98d040
> > > > > Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> > > > > Control: 10c5387d  Table: 6deb406a  DAC: 0051
> > > > > Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
> > > > > Stack: (0xee871db8 to 0xee872000)
> > > > > 1da0:   
> > > > > ee871e14 103ace2d
> > > > > 1dc0:    ee871e14 0005  
> > > > > c08524a0 
> > > > > 1de0: e000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 
> > > > > c0851120 c014bef0
> > > > > 1e00:  b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 
> > > > > ee871ecb 
> > > > > 1e20: 0008 103ace2d  c087e248 ee29c868 103ace2d 
> > > > > 0001 
> > > > > 1e40:  ee871e98 0006  c0fb2a50 c087e2d0 
> > > > >  c08523c4
> > > > > 1e60:  c014bdfc 0006 c0fad2d0 ee871e98 ee89f710 
> > > > >  c014c500
> > > > > 1e80:  ee89f3c0 c0f04c48  ee9e5000 c087dfb4 
> > > > > ee9e5000 
> > > > > 1ea0: ee89f710 ee871ecb 0001 103ace2d  c0f04c48 
> > > > >  c087e0a8
> > > > > 1ec0:  efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 
> > > > > ee9e5000 0122
> > > > > 1ee0: 0100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 
> > > > > 2e928000 c0fad2ec
> > > > > 1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400  c087def8 
> > > > > c0fad2ec c01447dc
> > > > > 1f20: ef315640 ef7a62c0 0008 ee839580 ee839594 ef7a62c0 
> > > > > 0008 c0f03d00
> > > > > 1f40: ef7a62d8 ef7a62c0 e000 c0145b84 e000 c0fb2420 
> > > > > c0bfaa8c 
> > > > > 1f60: e000 ee84b600 ee84b5c0  ee87 ee839580 
> > > > > c0145b40 ef0e5ea4
> > > > > 1f80: ee84b61c c014a6f8 0001 ee84b5c0 c014a5b0  
> > > > >  
> > > > > 1fa0:    c01010e8   
> > > > >  
> > > > > 1fc0:       
> > > > >  
> > > > > 1fe0:     0013  
> > > > >  
> > > > > [] 

Re: [PATCH net v2] net: dsa: Check existence of .port_mdb_add callback before calling it

2019-08-06 Thread Chen-Yu Tsai
On Wed, Aug 7, 2019 at 4:34 AM Vivien Didelot  wrote:
>
> Hi Chen-Yu,
>
> On Wed, 7 Aug 2019 01:49:37 +0800, Chen-Yu Tsai  wrote:
> > On Wed, Aug 7, 2019 at 1:15 AM Vivien Didelot  
> > wrote:
> > >
> > > Hi Chen-Yu,
> > >
> > > On Tue,  6 Aug 2019 15:53:25 +0800, Chen-Yu Tsai  wrote:
> > > > From: Chen-Yu Tsai 
> > > >
> > > > With the recent addition of commit 75dad2520fc3 ("net: dsa: b53: Disable
> > > > all ports on setup"), users of b53 (BCM53125 on Lamobo R1 in my case)
> > > > are forced to use the dsa subsystem to enable the switch, instead of
> > > > having it in the default transparent "forward-to-all" mode.
> > > >
> > > > The b53 driver does not support mdb bitmap functions. However the dsa
> > > > layer does not check for the existence of the .port_mdb_add callback
> > > > before actually using it. This results in a NULL pointer dereference,
> > > > as shown in the kernel oops below.
> > > >
> > > > The other functions seem to be properly guarded. Do the same for
> > > > .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.
> > > >
> > > > b53 is not the only driver that doesn't support mdb bitmap functions.
> > > > Others include bcm_sf2, dsa_loop, lantiq_gswip, mt7530, mv88e6060,
> > > > qca8k, realtek-smi, and vitesse-vsc73xx.
> > >
> > > I don't know what you mean by that, there's no "mdb bitmap function"
> > > support for drivers, only the port_mdb_{prepare,add,del} callbacks...
> >
> > The term was coined from commit e6db98db8a95 ("net: dsa: add switch mdb
> > bitmap functions"). But yeah, .port_mdb_* ops/callbacks would be more
> > appropriate.
> >
> > > > 8<--- cut here ---
> > > > Unable to handle kernel NULL pointer dereference at virtual address 
> > > > 
> > > > pgd = (ptrval)
> > > > [] *pgd=
> > > > Internal error: Oops: 8005 [#1] SMP ARM
> > > > Modules linked in: rtl8xxxu rtl8192cu rtl_usb rtl8192c_common 
> > > > rtlwifi mac80211 cfg80211
> > > > CPU: 1 PID: 134 Comm: kworker/1:2 Not tainted 
> > > > 5.3.0-rc1-00247-gd3519030752a #1
> > > > Hardware name: Allwinner sun7i (A20) Family
> > > > Workqueue: events switchdev_deferred_process_work
> > > > PC is at 0x0
> > > > LR is at dsa_switch_event+0x570/0x620
> > > > pc : [<>]lr : []psr: 80070013
> > > > sp : ee871db8  ip :   fp : ee98d0a4
> > > > r10: 000c  r9 : 0008  r8 : ee89f710
> > > > r7 : ee98d040  r6 : ee98d088  r5 : c0f04c48  r4 : ee98d04c
> > > > r3 :   r2 : ee89f710  r1 : 0008  r0 : ee98d040
> > > > Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> > > > Control: 10c5387d  Table: 6deb406a  DAC: 0051
> > > > Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
> > > > Stack: (0xee871db8 to 0xee872000)
> > > > 1da0:   
> > > > ee871e14 103ace2d
> > > > 1dc0:    ee871e14 0005  
> > > > c08524a0 
> > > > 1de0: e000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 
> > > > c0851120 c014bef0
> > > > 1e00:  b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 
> > > > ee871ecb 
> > > > 1e20: 0008 103ace2d  c087e248 ee29c868 103ace2d 
> > > > 0001 
> > > > 1e40:  ee871e98 0006  c0fb2a50 c087e2d0 
> > > >  c08523c4
> > > > 1e60:  c014bdfc 0006 c0fad2d0 ee871e98 ee89f710 
> > > >  c014c500
> > > > 1e80:  ee89f3c0 c0f04c48  ee9e5000 c087dfb4 
> > > > ee9e5000 
> > > > 1ea0: ee89f710 ee871ecb 0001 103ace2d  c0f04c48 
> > > >  c087e0a8
> > > > 1ec0:  efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 
> > > > ee9e5000 0122
> > > > 1ee0: 0100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 
> > > > 2e928000 c0fad2ec
> > > > 1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400  c087def8 
> > > > c0fad2ec c01447dc
> > > > 1f20: ef315640 ef7a62c0 0008 ee839580 ee839594 ef7a62c0 
> > > > 0008 c0f03d00
> > > > 1f40: ef7a62d8 ef7a62c0 e000 c0145b84 e000 c0fb2420 
> > > > c0bfaa8c 
> > > > 1f60: e000 ee84b600 ee84b5c0  ee87 ee839580 
> > > > c0145b40 ef0e5ea4
> > > > 1f80: ee84b61c c014a6f8 0001 ee84b5c0 c014a5b0  
> > > >  
> > > > 1fa0:    c01010e8   
> > > >  
> > > > 1fc0:       
> > > >  
> > > > 1fe0:     0013  
> > > >  
> > > > [] (dsa_switch_event) from [] 
> > > > (notifier_call_chain+0x48/0x84)
> > > > [] (notifier_call_chain) from [] 
> > > > (raw_notifier_call_chain+0x18/0x20)
> > > > [] (raw_notifier_call_chain) from [] 
> > > > (dsa_port_mdb_add+0x48/0x74)
> > > > [] (dsa_port_mdb_add) from [] 
> 

Re: [PATCH net v2] net: dsa: Check existence of .port_mdb_add callback before calling it

2019-08-06 Thread Vivien Didelot
Hi Chen-Yu,

On Wed, 7 Aug 2019 01:49:37 +0800, Chen-Yu Tsai  wrote:
> On Wed, Aug 7, 2019 at 1:15 AM Vivien Didelot  
> wrote:
> >
> > Hi Chen-Yu,
> >
> > On Tue,  6 Aug 2019 15:53:25 +0800, Chen-Yu Tsai  wrote:
> > > From: Chen-Yu Tsai 
> > >
> > > With the recent addition of commit 75dad2520fc3 ("net: dsa: b53: Disable
> > > all ports on setup"), users of b53 (BCM53125 on Lamobo R1 in my case)
> > > are forced to use the dsa subsystem to enable the switch, instead of
> > > having it in the default transparent "forward-to-all" mode.
> > >
> > > The b53 driver does not support mdb bitmap functions. However the dsa
> > > layer does not check for the existence of the .port_mdb_add callback
> > > before actually using it. This results in a NULL pointer dereference,
> > > as shown in the kernel oops below.
> > >
> > > The other functions seem to be properly guarded. Do the same for
> > > .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.
> > >
> > > b53 is not the only driver that doesn't support mdb bitmap functions.
> > > Others include bcm_sf2, dsa_loop, lantiq_gswip, mt7530, mv88e6060,
> > > qca8k, realtek-smi, and vitesse-vsc73xx.
> >
> > I don't know what you mean by that, there's no "mdb bitmap function"
> > support for drivers, only the port_mdb_{prepare,add,del} callbacks...
> 
> The term was coined from commit e6db98db8a95 ("net: dsa: add switch mdb
> bitmap functions"). But yeah, .port_mdb_* ops/callbacks would be more
> appropriate.
> 
> > > 8<--- cut here ---
> > > Unable to handle kernel NULL pointer dereference at virtual address 
> > > 
> > > pgd = (ptrval)
> > > [] *pgd=
> > > Internal error: Oops: 8005 [#1] SMP ARM
> > > Modules linked in: rtl8xxxu rtl8192cu rtl_usb rtl8192c_common rtlwifi 
> > > mac80211 cfg80211
> > > CPU: 1 PID: 134 Comm: kworker/1:2 Not tainted 
> > > 5.3.0-rc1-00247-gd3519030752a #1
> > > Hardware name: Allwinner sun7i (A20) Family
> > > Workqueue: events switchdev_deferred_process_work
> > > PC is at 0x0
> > > LR is at dsa_switch_event+0x570/0x620
> > > pc : [<>]lr : []psr: 80070013
> > > sp : ee871db8  ip :   fp : ee98d0a4
> > > r10: 000c  r9 : 0008  r8 : ee89f710
> > > r7 : ee98d040  r6 : ee98d088  r5 : c0f04c48  r4 : ee98d04c
> > > r3 :   r2 : ee89f710  r1 : 0008  r0 : ee98d040
> > > Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> > > Control: 10c5387d  Table: 6deb406a  DAC: 0051
> > > Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
> > > Stack: (0xee871db8 to 0xee872000)
> > > 1da0:   ee871e14 
> > > 103ace2d
> > > 1dc0:    ee871e14 0005  c08524a0 
> > > 
> > > 1de0: e000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 c0851120 
> > > c014bef0
> > > 1e00:  b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 ee871ecb 
> > > 
> > > 1e20: 0008 103ace2d  c087e248 ee29c868 103ace2d 0001 
> > > 
> > > 1e40:  ee871e98 0006  c0fb2a50 c087e2d0  
> > > c08523c4
> > > 1e60:  c014bdfc 0006 c0fad2d0 ee871e98 ee89f710  
> > > c014c500
> > > 1e80:  ee89f3c0 c0f04c48  ee9e5000 c087dfb4 ee9e5000 
> > > 
> > > 1ea0: ee89f710 ee871ecb 0001 103ace2d  c0f04c48  
> > > c087e0a8
> > > 1ec0:  efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 ee9e5000 
> > > 0122
> > > 1ee0: 0100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 2e928000 
> > > c0fad2ec
> > > 1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400  c087def8 c0fad2ec 
> > > c01447dc
> > > 1f20: ef315640 ef7a62c0 0008 ee839580 ee839594 ef7a62c0 0008 
> > > c0f03d00
> > > 1f40: ef7a62d8 ef7a62c0 e000 c0145b84 e000 c0fb2420 c0bfaa8c 
> > > 
> > > 1f60: e000 ee84b600 ee84b5c0  ee87 ee839580 c0145b40 
> > > ef0e5ea4
> > > 1f80: ee84b61c c014a6f8 0001 ee84b5c0 c014a5b0   
> > > 
> > > 1fa0:    c01010e8    
> > > 
> > > 1fc0:        
> > > 
> > > 1fe0:     0013   
> > > 
> > > [] (dsa_switch_event) from [] 
> > > (notifier_call_chain+0x48/0x84)
> > > [] (notifier_call_chain) from [] 
> > > (raw_notifier_call_chain+0x18/0x20)
> > > [] (raw_notifier_call_chain) from [] 
> > > (dsa_port_mdb_add+0x48/0x74)
> > > [] (dsa_port_mdb_add) from [] 
> > > (__switchdev_handle_port_obj_add+0x54/0xd4)
> > > [] (__switchdev_handle_port_obj_add) from [] 
> > > (switchdev_handle_port_obj_add+0x8/0x14)
> > > [] (switchdev_handle_port_obj_add) from [] 
> > > (dsa_slave_switchdev_blocking_event+0x94/0xa4)
>

Re: [PATCH net v2] net: dsa: Check existence of .port_mdb_add callback before calling it

2019-08-06 Thread Chen-Yu Tsai
On Wed, Aug 7, 2019 at 1:15 AM Vivien Didelot  wrote:
>
> Hi Chen-Yu,
>
> On Tue,  6 Aug 2019 15:53:25 +0800, Chen-Yu Tsai  wrote:
> > From: Chen-Yu Tsai 
> >
> > With the recent addition of commit 75dad2520fc3 ("net: dsa: b53: Disable
> > all ports on setup"), users of b53 (BCM53125 on Lamobo R1 in my case)
> > are forced to use the dsa subsystem to enable the switch, instead of
> > having it in the default transparent "forward-to-all" mode.
> >
> > The b53 driver does not support mdb bitmap functions. However the dsa
> > layer does not check for the existence of the .port_mdb_add callback
> > before actually using it. This results in a NULL pointer dereference,
> > as shown in the kernel oops below.
> >
> > The other functions seem to be properly guarded. Do the same for
> > .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.
> >
> > b53 is not the only driver that doesn't support mdb bitmap functions.
> > Others include bcm_sf2, dsa_loop, lantiq_gswip, mt7530, mv88e6060,
> > qca8k, realtek-smi, and vitesse-vsc73xx.
>
> I don't know what you mean by that, there's no "mdb bitmap function"
> support for drivers, only the port_mdb_{prepare,add,del} callbacks...

The term was coined from commit e6db98db8a95 ("net: dsa: add switch mdb
bitmap functions"). But yeah, .port_mdb_* ops/callbacks would be more
appropriate.

> > 8<--- cut here ---
> > Unable to handle kernel NULL pointer dereference at virtual address 
> > 
> > pgd = (ptrval)
> > [] *pgd=
> > Internal error: Oops: 8005 [#1] SMP ARM
> > Modules linked in: rtl8xxxu rtl8192cu rtl_usb rtl8192c_common rtlwifi 
> > mac80211 cfg80211
> > CPU: 1 PID: 134 Comm: kworker/1:2 Not tainted 
> > 5.3.0-rc1-00247-gd3519030752a #1
> > Hardware name: Allwinner sun7i (A20) Family
> > Workqueue: events switchdev_deferred_process_work
> > PC is at 0x0
> > LR is at dsa_switch_event+0x570/0x620
> > pc : [<>]lr : []psr: 80070013
> > sp : ee871db8  ip :   fp : ee98d0a4
> > r10: 000c  r9 : 0008  r8 : ee89f710
> > r7 : ee98d040  r6 : ee98d088  r5 : c0f04c48  r4 : ee98d04c
> > r3 :   r2 : ee89f710  r1 : 0008  r0 : ee98d040
> > Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> > Control: 10c5387d  Table: 6deb406a  DAC: 0051
> > Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
> > Stack: (0xee871db8 to 0xee872000)
> > 1da0:   ee871e14 
> > 103ace2d
> > 1dc0:    ee871e14 0005  c08524a0 
> > 
> > 1de0: e000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 c0851120 
> > c014bef0
> > 1e00:  b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 ee871ecb 
> > 
> > 1e20: 0008 103ace2d  c087e248 ee29c868 103ace2d 0001 
> > 
> > 1e40:  ee871e98 0006  c0fb2a50 c087e2d0  
> > c08523c4
> > 1e60:  c014bdfc 0006 c0fad2d0 ee871e98 ee89f710  
> > c014c500
> > 1e80:  ee89f3c0 c0f04c48  ee9e5000 c087dfb4 ee9e5000 
> > 
> > 1ea0: ee89f710 ee871ecb 0001 103ace2d  c0f04c48  
> > c087e0a8
> > 1ec0:  efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 ee9e5000 
> > 0122
> > 1ee0: 0100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 2e928000 
> > c0fad2ec
> > 1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400  c087def8 c0fad2ec 
> > c01447dc
> > 1f20: ef315640 ef7a62c0 0008 ee839580 ee839594 ef7a62c0 0008 
> > c0f03d00
> > 1f40: ef7a62d8 ef7a62c0 e000 c0145b84 e000 c0fb2420 c0bfaa8c 
> > 
> > 1f60: e000 ee84b600 ee84b5c0  ee87 ee839580 c0145b40 
> > ef0e5ea4
> > 1f80: ee84b61c c014a6f8 0001 ee84b5c0 c014a5b0   
> > 
> > 1fa0:    c01010e8    
> > 
> > 1fc0:        
> > 
> > 1fe0:     0013   
> > 
> > [] (dsa_switch_event) from [] 
> > (notifier_call_chain+0x48/0x84)
> > [] (notifier_call_chain) from [] 
> > (raw_notifier_call_chain+0x18/0x20)
> > [] (raw_notifier_call_chain) from [] 
> > (dsa_port_mdb_add+0x48/0x74)
> > [] (dsa_port_mdb_add) from [] 
> > (__switchdev_handle_port_obj_add+0x54/0xd4)
> > [] (__switchdev_handle_port_obj_add) from [] 
> > (switchdev_handle_port_obj_add+0x8/0x14)
> > [] (switchdev_handle_port_obj_add) from [] 
> > (dsa_slave_switchdev_blocking_event+0x94/0xa4)
> > [] (dsa_slave_switchdev_blocking_event) from [] 
> > (notifier_call_chain+0x48/0x84)
> > [] (notifier_call_chain) from [] 
> > (blocking_notifier_call_chain+0x50/0x68)
> > [] (blocking_notifier_call_chain) from [] 
> > (switchdev_port_obj_notify+0x44/0xa8)
> > 

Re: [PATCH net v2] net: dsa: Check existence of .port_mdb_add callback before calling it

2019-08-06 Thread Vivien Didelot
Hi Chen-Yu,

On Tue,  6 Aug 2019 15:53:25 +0800, Chen-Yu Tsai  wrote:
> From: Chen-Yu Tsai 
> 
> With the recent addition of commit 75dad2520fc3 ("net: dsa: b53: Disable
> all ports on setup"), users of b53 (BCM53125 on Lamobo R1 in my case)
> are forced to use the dsa subsystem to enable the switch, instead of
> having it in the default transparent "forward-to-all" mode.
> 
> The b53 driver does not support mdb bitmap functions. However the dsa
> layer does not check for the existence of the .port_mdb_add callback
> before actually using it. This results in a NULL pointer dereference,
> as shown in the kernel oops below.
> 
> The other functions seem to be properly guarded. Do the same for
> .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.
> 
> b53 is not the only driver that doesn't support mdb bitmap functions.
> Others include bcm_sf2, dsa_loop, lantiq_gswip, mt7530, mv88e6060,
> qca8k, realtek-smi, and vitesse-vsc73xx.

I don't know what you mean by that, there's no "mdb bitmap function"
support for drivers, only the port_mdb_{prepare,add,del} callbacks...
> 
> 8<--- cut here ---
> Unable to handle kernel NULL pointer dereference at virtual address 
> 
> pgd = (ptrval)
> [] *pgd=
> Internal error: Oops: 8005 [#1] SMP ARM
> Modules linked in: rtl8xxxu rtl8192cu rtl_usb rtl8192c_common rtlwifi 
> mac80211 cfg80211
> CPU: 1 PID: 134 Comm: kworker/1:2 Not tainted 
> 5.3.0-rc1-00247-gd3519030752a #1
> Hardware name: Allwinner sun7i (A20) Family
> Workqueue: events switchdev_deferred_process_work
> PC is at 0x0
> LR is at dsa_switch_event+0x570/0x620
> pc : [<>]lr : []psr: 80070013
> sp : ee871db8  ip :   fp : ee98d0a4
> r10: 000c  r9 : 0008  r8 : ee89f710
> r7 : ee98d040  r6 : ee98d088  r5 : c0f04c48  r4 : ee98d04c
> r3 :   r2 : ee89f710  r1 : 0008  r0 : ee98d040
> Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> Control: 10c5387d  Table: 6deb406a  DAC: 0051
> Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
> Stack: (0xee871db8 to 0xee872000)
> 1da0:   ee871e14 
> 103ace2d
> 1dc0:    ee871e14 0005  c08524a0 
> 
> 1de0: e000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 c0851120 
> c014bef0
> 1e00:  b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 ee871ecb 
> 
> 1e20: 0008 103ace2d  c087e248 ee29c868 103ace2d 0001 
> 
> 1e40:  ee871e98 0006  c0fb2a50 c087e2d0  
> c08523c4
> 1e60:  c014bdfc 0006 c0fad2d0 ee871e98 ee89f710  
> c014c500
> 1e80:  ee89f3c0 c0f04c48  ee9e5000 c087dfb4 ee9e5000 
> 
> 1ea0: ee89f710 ee871ecb 0001 103ace2d  c0f04c48  
> c087e0a8
> 1ec0:  efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 ee9e5000 
> 0122
> 1ee0: 0100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 2e928000 
> c0fad2ec
> 1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400  c087def8 c0fad2ec 
> c01447dc
> 1f20: ef315640 ef7a62c0 0008 ee839580 ee839594 ef7a62c0 0008 
> c0f03d00
> 1f40: ef7a62d8 ef7a62c0 e000 c0145b84 e000 c0fb2420 c0bfaa8c 
> 
> 1f60: e000 ee84b600 ee84b5c0  ee87 ee839580 c0145b40 
> ef0e5ea4
> 1f80: ee84b61c c014a6f8 0001 ee84b5c0 c014a5b0   
> 
> 1fa0:    c01010e8    
> 
> 1fc0:        
> 
> 1fe0:     0013   
> 
> [] (dsa_switch_event) from [] 
> (notifier_call_chain+0x48/0x84)
> [] (notifier_call_chain) from [] 
> (raw_notifier_call_chain+0x18/0x20)
> [] (raw_notifier_call_chain) from [] 
> (dsa_port_mdb_add+0x48/0x74)
> [] (dsa_port_mdb_add) from [] 
> (__switchdev_handle_port_obj_add+0x54/0xd4)
> [] (__switchdev_handle_port_obj_add) from [] 
> (switchdev_handle_port_obj_add+0x8/0x14)
> [] (switchdev_handle_port_obj_add) from [] 
> (dsa_slave_switchdev_blocking_event+0x94/0xa4)
> [] (dsa_slave_switchdev_blocking_event) from [] 
> (notifier_call_chain+0x48/0x84)
> [] (notifier_call_chain) from [] 
> (blocking_notifier_call_chain+0x50/0x68)
> [] (blocking_notifier_call_chain) from [] 
> (switchdev_port_obj_notify+0x44/0xa8)
> [] (switchdev_port_obj_notify) from [] 
> (switchdev_port_obj_add_now+0x90/0x104)
> [] (switchdev_port_obj_add_now) from [] 
> (switchdev_port_obj_add_deferred+0x14/0x5c)
> [] (switchdev_port_obj_add_deferred) from [] 
> (switchdev_deferred_process+0x64/0x104)
> [] (switchdev_deferred_process) from [] 
> (switchdev_deferred_process_work+0xc/0x14)
> [] (switchdev_deferred_process_work) from []