diff options
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) | |||
625 | s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]); | 625 | s_firmLoad[i] = CPU_CHIP_SWAP32(s_firmLoad[i]); |
626 | } | 626 | } |
627 | 627 | ||
628 | static int bdx_range_check(struct bdx_priv *priv, u32 offset) | ||
629 | { | ||
630 | return (offset > (u32) (BDX_REGS_SIZE / priv->nic->port_num)) ? | ||
631 | -EINVAL : 0; | ||
632 | } | ||
633 | |||
628 | static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | 634 | static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) |
629 | { | 635 | { |
630 | struct bdx_priv *priv = ndev->priv; | 636 | struct bdx_priv *priv = ndev->priv; |
@@ -643,9 +649,15 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | |||
643 | DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); | 649 | DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); |
644 | } | 650 | } |
645 | 651 | ||
652 | if (!capable(CAP_NET_ADMIN)) | ||
653 | return -EPERM; | ||
654 | |||
646 | switch (data[0]) { | 655 | switch (data[0]) { |
647 | 656 | ||
648 | case BDX_OP_READ: | 657 | case BDX_OP_READ: |
658 | error = bdx_range_check(priv, data[1]); | ||
659 | if (error < 0) | ||
660 | return error; | ||
649 | data[2] = READ_REG(priv, data[1]); | 661 | data[2] = READ_REG(priv, data[1]); |
650 | DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], | 662 | DBG("read_reg(0x%x)=0x%x (dec %d)\n", data[1], data[2], |
651 | data[2]); | 663 | data[2]); |
@@ -655,6 +667,9 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | |||
655 | break; | 667 | break; |
656 | 668 | ||
657 | case BDX_OP_WRITE: | 669 | case BDX_OP_WRITE: |
670 | error = bdx_range_check(priv, data[1]); | ||
671 | if (error < 0) | ||
672 | return error; | ||
658 | WRITE_REG(priv, data[1], data[2]); | 673 | WRITE_REG(priv, data[1], data[2]); |
659 | DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]); | 674 | DBG("write_reg(0x%x, 0x%x)\n", data[1], data[2]); |
660 | break; | 675 | break; |