net: dsa: fix panic when removing unoffloaded port from bridge
Alvin Šipraga authored
If a bridged port is not offloaded to the hardware - either because the
underlying driver does not implement the port_bridge_{join,leave} ops,
or because the operation failed - then its dp->bridge pointer will be
NULL when dsa_port_bridge_leave() is called. Avoid dereferncing NULL.

This fixes the following splat when removing a port from a bridge:

 Unable to handle kernel access to user memory outside uaccess routines at virtual address 0000000000000000
 Internal error: Oops: 96000004 [#1] PREEMPT_RT SMP
 CPU: 3 PID: 1119 Comm: brctl Tainted: G           O      5.17.0-rc4-rt4 #1
 Call trace:
  dsa_port_bridge_leave+0x8c/0x1e4
  dsa_slave_changeupper+0x40/0x170
  dsa_slave_netdevice_event+0x494/0x4d4
  notifier_call_chain+0x80/0xe0
  raw_notifier_call_chain+0x1c/0x24
  call_netdevice_notifiers_info+0x5c/0xac
  __netdev_upper_dev_unlink+0xa4/0x200
  netdev_upper_dev_unlink+0x38/0x60
  del_nbp+0x1b0/0x300
  br_del_if+0x38/0x114
  add_del_if+0x6...
342b6419
Name Last commit Last update
..
Kconfig net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag
Makefile net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag
dsa.c net: dsa: mv88e6xxx: flush switchdev FDB workqueue before removing VLAN
dsa2.c net: dsa: fix panic when DSA master device unbinds on shutdown
dsa_priv.h net: dsa: mv88e6xxx: flush switchdev FDB workqueue before removing VLAN
master.c net: dsa: avoid call to __dev_set_promiscuity() while rtnl_mutex isn't held
port.c net: dsa: fix panic when removing unoffloaded port from bridge
slave.c net: dsa: merge rtnl_lock sections in dsa_slave_create
switch.c net: dsa: remove cross-chip support for HSR
tag_8021q.c net: dsa: keep the bridge_dev and bridge_num as part of the same structure
tag_ar9331.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv()
tag_brcm.c net: dsa: create a helper for locating EtherType DSA headers on RX
tag_dsa.c net: dsa: hide dp->bridge_dev and dp->bridge_num in the core behind helpers
tag_gswip.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv()
tag_hellcreek.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv()
tag_ksz.c net/dsa/tag_ksz.c: remove superfluous headers
tag_lan9303.c net: dsa: lan9303: handle hwaccel VLAN tags
tag_mtk.c net: dsa: create a helper for locating EtherType DSA headers on TX
tag_ocelot.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
tag_ocelot_8021q.c net: dsa: make tagging protocols connect to individual switches from a tree
tag_qca.c net: dsa: create a helper for locating EtherType DSA headers on TX
tag_rtl4_a.c net: dsa: tag_rtl4_a: Drop bit 9 from egress frames
tag_rtl8_4.c net: dsa: tag_rtl8_4: add realtek 8 byte protocol 4 tag
tag_sja1105.c net: dsa: make tagging protocols connect to individual switches from a tree
tag_trailer.c net: dsa: remove the struct packet_type argument from dsa_device_ops::rcv()
tag_xrs700x.c