Commit 3c18aa14 authored by Colin Ian King's avatar Colin Ian King Committed by David S. Miller

net: qualcomm: rmnet: move null check on dev before dereferecing it

Currently dev is dereferenced by the call dev_net(dev) before dev is null
checked.  Fix this by null checking dev before the potential null
pointer dereference.

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

Fixes: 23790ef1 ("net: qualcomm: rmnet: Allow to configure flags for existing devices")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 21ab664a
...@@ -301,10 +301,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[], ...@@ -301,10 +301,13 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[],
struct rmnet_port *port; struct rmnet_port *port;
u16 mux_id; u16 mux_id;
if (!dev)
return -ENODEV;
real_dev = __dev_get_by_index(dev_net(dev), real_dev = __dev_get_by_index(dev_net(dev),
nla_get_u32(tb[IFLA_LINK])); nla_get_u32(tb[IFLA_LINK]));
if (!real_dev || !dev || !rmnet_is_real_dev_registered(real_dev)) if (!real_dev || !rmnet_is_real_dev_registered(real_dev))
return -ENODEV; return -ENODEV;
port = rmnet_get_port_rtnl(real_dev); port = rmnet_get_port_rtnl(real_dev);
......
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