bnx2x: fix dump flag handling
authorMichal Schmidt <mschmidt@redhat.com>
Mon, 1 Jul 2013 15:23:06 +0000 (17:23 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jul 2013 07:15:56 +0000 (00:15 -0700)
bnx2x interprets the dump flag as an index of a register preset.
It is important to validate the index to avoid out of bounds
memory accesses.

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

index 4f75ae854b3d933aa7b60011146ceccbb5f3918b..cf5cebc358b81aa4a93de4af3d1ac9ac20d704fa 100644 (file)
@@ -959,6 +959,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
        struct bnx2x *bp = netdev_priv(dev);
 
        /* Use the ethtool_dump "flag" field as the dump preset index */
+       if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
+               return -EINVAL;
+
        bp->dump_preset_idx = val->flag;
        return 0;
 }
index 740518bbcb5ffa159c976d93d9774be6c2aa9733..15a528bda87ccc60cb757e872e12eac296867681 100644 (file)
@@ -11636,6 +11636,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
                bp->min_msix_vec_cnt = 2;
        BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
 
+       bp->dump_preset_idx = 1;
+
        return rc;
 }