diff options
author | Arvid Brodin <arvid.brodin@alten.se> | 2014-07-04 17:42:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-08 14:35:31 -0400 |
commit | a718dcc5e56546a62d00f57cc875faac2f42c8bf (patch) | |
tree | 35ea41cdc4e877c852fba2f82077964e1458dfe5 /net/hsr/hsr_netlink.c | |
parent | f266a683a4804dc499efc6c2206ef68efed029d0 (diff) |
net/hsr: Fix NULL pointer dereference on incomplete hsr_newlink() params.
If none of the slave interfaces are specified, struct nlattr *data[] may
be NULL. Make sure to check for that.
While I'm at it, fix the horrible error messages displayed when only one
of the slave interfaces isn't specified.
Signed-off-by: Arvid Brodin <arvid.brodin@alten.se>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/hsr/hsr_netlink.c')
-rw-r--r-- | net/hsr/hsr_netlink.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index fbdf53f1d874..a2c7e4c0ac1e 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c | |||
@@ -37,13 +37,17 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev, | |||
37 | struct net_device *link[2]; | 37 | struct net_device *link[2]; |
38 | unsigned char multicast_spec; | 38 | unsigned char multicast_spec; |
39 | 39 | ||
40 | if (!data) { | ||
41 | netdev_info(dev, "HSR: No slave devices specified\n"); | ||
42 | return -EINVAL; | ||
43 | } | ||
40 | if (!data[IFLA_HSR_SLAVE1]) { | 44 | if (!data[IFLA_HSR_SLAVE1]) { |
41 | netdev_info(dev, "IFLA_HSR_SLAVE1 missing!\n"); | 45 | netdev_info(dev, "HSR: Slave1 device not specified\n"); |
42 | return -EINVAL; | 46 | return -EINVAL; |
43 | } | 47 | } |
44 | link[0] = __dev_get_by_index(src_net, nla_get_u32(data[IFLA_HSR_SLAVE1])); | 48 | link[0] = __dev_get_by_index(src_net, nla_get_u32(data[IFLA_HSR_SLAVE1])); |
45 | if (!data[IFLA_HSR_SLAVE2]) { | 49 | if (!data[IFLA_HSR_SLAVE2]) { |
46 | netdev_info(dev, "IFLA_HSR_SLAVE2 missing!\n"); | 50 | netdev_info(dev, "HSR: Slave2 device not specified\n"); |
47 | return -EINVAL; | 51 | return -EINVAL; |
48 | } | 52 | } |
49 | link[1] = __dev_get_by_index(src_net, nla_get_u32(data[IFLA_HSR_SLAVE2])); | 53 | link[1] = __dev_get_by_index(src_net, nla_get_u32(data[IFLA_HSR_SLAVE2])); |