Skip to content

Commit

Permalink
net/hsr: Fix NULL pointer dereference on incomplete hsr_newlink() par…
Browse files Browse the repository at this point in the history
…ams.

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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Arvid Brodin authored and davem330 committed Jul 8, 2014
1 parent f266a68 commit a718dcc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions net/hsr/hsr_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev,
struct net_device *link[2];
unsigned char multicast_spec;

if (!data) {
netdev_info(dev, "HSR: No slave devices specified\n");
return -EINVAL;
}
if (!data[IFLA_HSR_SLAVE1]) {
netdev_info(dev, "IFLA_HSR_SLAVE1 missing!\n");
netdev_info(dev, "HSR: Slave1 device not specified\n");
return -EINVAL;
}
link[0] = __dev_get_by_index(src_net, nla_get_u32(data[IFLA_HSR_SLAVE1]));
if (!data[IFLA_HSR_SLAVE2]) {
netdev_info(dev, "IFLA_HSR_SLAVE2 missing!\n");
netdev_info(dev, "HSR: Slave2 device not specified\n");
return -EINVAL;
}
link[1] = __dev_get_by_index(src_net, nla_get_u32(data[IFLA_HSR_SLAVE2]));
Expand Down

0 comments on commit a718dcc

Please sign in to comment.