Commit 1fd0bddb authored by Roopa Prabhu's avatar Roopa Prabhu Committed by David S. Miller

bridge: add missing bridge port check for offloads

This patch fixes a missing bridge port check caught by smatch.

setlink/dellink of attributes like vlans can come for a bridge device
and there is no need to offload those today. So, this patch adds a bridge
port check. (In these cases however, the BRIDGE_SELF flags will always be set
and we may not hit a problem with the current code).

smatch complaint:

The patch 68e331c7: "bridge: offload bridge port attributes to
switch asic if feature flag set" from Jan 29, 2015, leads to the
following Smatch complaint:

net/bridge/br_netlink.c:552 br_setlink()
	 error: we previously assumed 'p' could be null (see line 518)

net/bridge/br_netlink.c
   517
   518		if (p && protinfo) {
                    ^
Check for NULL.
Reported-By: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d78f802f
...@@ -543,7 +543,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -543,7 +543,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
afspec, RTM_SETLINK); afspec, RTM_SETLINK);
} }
if (!(flags & BRIDGE_FLAGS_SELF)) { if (p && !(flags & BRIDGE_FLAGS_SELF)) {
/* set bridge attributes in hardware if supported /* set bridge attributes in hardware if supported
*/ */
ret_offload = netdev_switch_port_bridge_setlink(dev, nlh, ret_offload = netdev_switch_port_bridge_setlink(dev, nlh,
...@@ -583,7 +583,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags) ...@@ -583,7 +583,7 @@ int br_dellink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags)
*/ */
br_ifinfo_notify(RTM_NEWLINK, p); br_ifinfo_notify(RTM_NEWLINK, p);
if (!(flags & BRIDGE_FLAGS_SELF)) { if (p && !(flags & BRIDGE_FLAGS_SELF)) {
/* del bridge attributes in hardware /* del bridge attributes in hardware
*/ */
ret_offload = netdev_switch_port_bridge_dellink(dev, nlh, ret_offload = netdev_switch_port_bridge_dellink(dev, nlh,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment