diff options
author | David S. Miller <davem@davemloft.net> | 2008-04-25 00:31:07 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-25 00:31:07 -0700 |
commit | cc93d7d77d28d65d4f947dabc95a01c42d713ea3 (patch) | |
tree | bdaa01a54c7d881b7087551daf85fa52c61b3d1c /drivers/net/tehuti.c | |
parent | 461e6c856faf9cdd8862fa4d0785974a64e39dba (diff) | |
parent | f946dffed6334f08da065a89ed65026ebf8b33b4 (diff) | |
download | blackbird-op-linux-cc93d7d77d28d65d4f947dabc95a01c42d713ea3.tar.gz blackbird-op-linux-cc93d7d77d28d65d4f947dabc95a01c42d713ea3.zip |
Merge branch 'upstream-davem' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
Diffstat (limited to 'drivers/net/tehuti.c')
-rw-r--r-- | drivers/net/tehuti.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c index 17585e5eed53..e83b166aa6b9 100644 --- a/drivers/net/tehuti.c +++ b/drivers/net/tehuti.c @@ -625,6 +625,12 @@ static void __init bdx_firmware_endianess(void) s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]); } +static int bdx_range_check(struct bdx_priv *priv, u32 offset) +{ + return (offset > (u32) (BDX_REGS_SIZE / priv->nic->port_num)) ? + -EINVAL : 0; +} + static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) { struct bdx_priv *priv = ndev->priv; @@ -643,9 +649,15 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); } + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + switch (data[0]) { case BDX_OP_READ: + error = bdx_range_check(priv, data[1]); + if (error < 0) + return error; data[2] = READ_REG(priv, data[1]); DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], data[2]); @@ -655,6 +667,9 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) break; case BDX_OP_WRITE: + error = bdx_range_check(priv, data[1]); + if (error < 0) + return error; WRITE_REG(priv, data[1], data[2]); DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]); break; |