kernel_optimize_test/net/bridge
Colin Ian King 40b1c813ba net: bridge: remove redundant checks for null p->dev and p->br
A recent change added a null check on p->dev after p->dev was being
dereferenced by the ns_capable check on p->dev. It turns out that
neither the p->dev and p->br null checks are necessary, and can be
removed, which cleans up a static analyis warning.

As Nikolay Aleksandrov noted, these checks can be removed because:

"My reasoning of why it shouldn't be possible:
- On port add new_nbp() sets both p->dev and p->br before creating
  kobj/sysfs

- On port del (trickier) del_nbp() calls kobject_del() before call_rcu()
  to destroy the port which in turn calls sysfs_remove_dir() which uses
  kernfs_remove() which deactivates (shouldn't be able to open new
  files) and calls kernfs_drain() to drain current open/mmaped files in
  the respective dir before continuing, thus making it impossible to
  open a bridge port sysfs file with p->dev and p->br equal to NULL.

So I think it's safe to remove those checks altogether. It'd be nice to
get a second look over my reasoning as I might be missing something in
sysfs/kernfs call path."

Thanks to Nikolay Aleksandrov's suggestion to remove the check and
David Miller for sanity checking this.

Detected by CoverityScan, CID#751490 ("Dereference before null check")

Fixes: a5f3ea54f3 ("net: bridge: add support for raw sysfs port options")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-11-25 10:25:43 -08:00
..
netfilter netfilter: bridge: Expose nf_tables bridge hook priorities through uapi 2018-08-03 21:15:09 +02:00
br_arp_nd_proxy.c net: bridge: convert neigh_suppress_enabled option to a bit 2018-09-26 10:04:23 -07:00
br_device.c netpoll: allow cleanup to be synchronous 2018-10-19 17:01:43 -07:00
br_fdb.c bridge: switchdev: Allow clearing FDB entry offload indication 2018-10-17 17:45:08 -07:00
br_forward.c net: bridge: add support for backup port 2018-07-23 09:32:15 -07:00
br_if.c bridge: Allow querying bridge port flags 2018-11-21 17:10:31 -08:00
br_input.c net: bridge: convert neigh_suppress_enabled option to a bit 2018-09-26 10:04:23 -07:00
br_ioctl.c
br_mdb.c net/bridge: Update br_mdb_dump for strict data checking 2018-10-08 10:39:05 -07:00
br_multicast.c net: bridge: remove ipv6 zero address check in mcast queries 2018-10-28 19:18:09 -07:00
br_netfilter_hooks.c bridge: use __vlan_hwaccel helpers 2018-11-08 20:45:04 -08:00
br_netfilter_ipv6.c
br_netlink_tunnel.c
br_netlink.c net: bridge: add support for per-port vlan stats 2018-10-12 10:18:58 -07:00
br_nf_core.c
br_private_stp.h
br_private_tunnel.h
br_private.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2018-11-19 10:55:00 -08:00
br_stp_bpdu.c
br_stp_if.c
br_stp_timer.c
br_stp.c
br_switchdev.c bridge: switchdev: Allow clearing FDB entry offload indication 2018-10-17 17:45:08 -07:00
br_sysfs_br.c net: bridge: add support for per-port vlan stats 2018-10-12 10:18:58 -07:00
br_sysfs_if.c net: bridge: remove redundant checks for null p->dev and p->br 2018-11-25 10:25:43 -08:00
br_vlan_tunnel.c
br_vlan.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2018-11-19 10:55:00 -08:00
br.c bridge: switchdev: Allow clearing FDB entry offload indication 2018-10-17 17:45:08 -07:00
Kconfig docs: fix some broken documentation references 2018-09-20 11:09:53 -06:00
Makefile