netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Toth <laszlth@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: bridge@lists.linux-foundation.org, netdev@vger.kernel.org
Subject: [PATCH] net: bridge: add missing NULL checks
Date: Sun, 8 Apr 2018 19:49:34 +0200	[thread overview]
Message-ID: <20180408174934.GA3895@laszlth> (raw)

br_port_get_rtnl() can return NULL

Signed-off-by: Laszlo Toth <laszlth@gmail.com>
---
 net/bridge/br_netlink.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 015f465c..cbec11f 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -939,14 +939,17 @@ static int br_port_slave_changelink(struct net_device *brdev,
 				    struct nlattr *data[],
 				    struct netlink_ext_ack *extack)
 {
+	struct net_bridge_port *port = br_port_get_rtnl(dev);
 	struct net_bridge *br = netdev_priv(brdev);
 	int ret;
 
 	if (!data)
 		return 0;
+	if (!port)
+		return -EINVAL;
 
 	spin_lock_bh(&br->lock);
-	ret = br_setport(br_port_get_rtnl(dev), data);
+	ret = br_setport(port, data);
 	spin_unlock_bh(&br->lock);
 
 	return ret;
@@ -956,7 +959,12 @@ static int br_port_fill_slave_info(struct sk_buff *skb,
 				   const struct net_device *brdev,
 				   const struct net_device *dev)
 {
-	return br_port_fill_attrs(skb, br_port_get_rtnl(dev));
+	struct net_bridge_port *port = br_port_get_rtnl(dev);
+
+	if (!port)
+		return -EINVAL;
+
+	return br_port_fill_attrs(skb, port);
 }
 
 static size_t br_port_get_slave_size(const struct net_device *brdev,
-- 
2.7.4

             reply	other threads:[~2018-04-08 17:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-08 17:49 Laszlo Toth [this message]
2018-04-08 22:25 ` [PATCH] net: bridge: add missing NULL checks Nikolay Aleksandrov
2018-04-10 17:22   ` Laszlo Toth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180408174934.GA3895@laszlth \
    --to=laszlth@gmail.com \
    --cc=bridge@lists.linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).