Skip to content

Commit e4fabf2

Browse files
Bhavesh Davdadavem330
Bhavesh Davda
authored andcommitted
vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
Linux is free to call ethtool ops as soon as a netdev exists when probe finishes. However, we only allocate vmxnet3 tx/rx queues and initialize the rx_buf_per_pkt field in struct vmxnet3_adapter when the interface is opened (UP). Signed-off-by: Bhavesh Davda <[email protected]> Signed-off-by: Shreyas N Bhatewara <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c5b1567 commit e4fabf2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

drivers/net/vmxnet3/vmxnet3_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
29582958

29592959
adapter->num_rx_queues = num_rx_queues;
29602960
adapter->num_tx_queues = num_tx_queues;
2961+
adapter->rx_buf_per_pkt = 1;
29612962

29622963
size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
29632964
size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues;

drivers/net/vmxnet3/vmxnet3_ethtool.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,12 @@ vmxnet3_set_ringparam(struct net_device *netdev,
472472
VMXNET3_RX_RING_MAX_SIZE)
473473
return -EINVAL;
474474

475+
/* if adapter not yet initialized, do nothing */
476+
if (adapter->rx_buf_per_pkt == 0) {
477+
netdev_err(netdev, "adapter not completely initialized, "
478+
"ring size cannot be changed yet\n");
479+
return -EOPNOTSUPP;
480+
}
475481

476482
/* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */
477483
new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) &

drivers/net/vmxnet3/vmxnet3_int.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@
7070
/*
7171
* Version numbers
7272
*/
73-
#define VMXNET3_DRIVER_VERSION_STRING "1.1.29.0-k"
73+
#define VMXNET3_DRIVER_VERSION_STRING "1.1.30.0-k"
7474

7575
/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
76-
#define VMXNET3_DRIVER_VERSION_NUM 0x01011D00
76+
#define VMXNET3_DRIVER_VERSION_NUM 0x01011E00
7777

7878
#if defined(CONFIG_PCI_MSI)
7979
/* RSS only makes sense if MSI-X is supported. */

0 commit comments

Comments
 (0)