Commit 00d521b3 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller

net: don't abuse "default" case for unknown ioctl in dev_ifsioc()

The "switch (cmd)" block from dev_ifsioc() gained a bit too much
unnecessary manual handling of "cmd" in the "default" case, starting
with the private ioctls.

Clean that up by using the "ellipsis" gcc extension, adding separate
cases for the rest of the ioctls, and letting the default case only
return -EINVAL.
Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 51aaa682
...@@ -391,36 +391,32 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data, ...@@ -391,36 +391,32 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
rtnl_lock(); rtnl_lock();
return err; return err;
case SIOCDEVPRIVATE ... SIOCDEVPRIVATE + 15:
return dev_siocdevprivate(dev, ifr, data, cmd);
case SIOCSHWTSTAMP: case SIOCSHWTSTAMP:
err = net_hwtstamp_validate(ifr); err = net_hwtstamp_validate(ifr);
if (err) if (err)
return err; return err;
fallthrough; fallthrough;
/* case SIOCGHWTSTAMP:
* Unknown or private ioctl case SIOCGMIIPHY:
*/ case SIOCGMIIREG:
default: case SIOCSMIIREG:
if (cmd >= SIOCDEVPRIVATE && return dev_eth_ioctl(dev, ifr, cmd);
cmd <= SIOCDEVPRIVATE + 15)
return dev_siocdevprivate(dev, ifr, data, cmd); case SIOCBONDENSLAVE:
case SIOCBONDRELEASE:
if (cmd == SIOCGMIIPHY || case SIOCBONDSETHWADDR:
cmd == SIOCGMIIREG || case SIOCBONDSLAVEINFOQUERY:
cmd == SIOCSMIIREG || case SIOCBONDINFOQUERY:
cmd == SIOCSHWTSTAMP || case SIOCBONDCHANGEACTIVE:
cmd == SIOCGHWTSTAMP) { return dev_siocbond(dev, ifr, cmd);
err = dev_eth_ioctl(dev, ifr, cmd);
} else if (cmd == SIOCBONDENSLAVE ||
cmd == SIOCBONDRELEASE ||
cmd == SIOCBONDSETHWADDR ||
cmd == SIOCBONDSLAVEINFOQUERY ||
cmd == SIOCBONDINFOQUERY ||
cmd == SIOCBONDCHANGEACTIVE) {
err = dev_siocbond(dev, ifr, cmd);
} else
err = -EINVAL;
/* Unknown ioctl */
default:
err = -EINVAL;
} }
return err; return err;
} }
......
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