Commit e4fabf2b authored by Bhavesh Davda's avatar Bhavesh Davda Committed by David S. Miller

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: default avatarBhavesh Davda <bhavesh@vmware.com>
Signed-off-by: default avatarShreyas N Bhatewara <sbhatewara@vmware.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5b15679
...@@ -2958,6 +2958,7 @@ vmxnet3_probe_device(struct pci_dev *pdev, ...@@ -2958,6 +2958,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
adapter->num_rx_queues = num_rx_queues; adapter->num_rx_queues = num_rx_queues;
adapter->num_tx_queues = num_tx_queues; adapter->num_tx_queues = num_tx_queues;
adapter->rx_buf_per_pkt = 1;
size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues; size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues; size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues;
......
...@@ -472,6 +472,12 @@ vmxnet3_set_ringparam(struct net_device *netdev, ...@@ -472,6 +472,12 @@ vmxnet3_set_ringparam(struct net_device *netdev,
VMXNET3_RX_RING_MAX_SIZE) VMXNET3_RX_RING_MAX_SIZE)
return -EINVAL; return -EINVAL;
/* if adapter not yet initialized, do nothing */
if (adapter->rx_buf_per_pkt == 0) {
netdev_err(netdev, "adapter not completely initialized, "
"ring size cannot be changed yet\n");
return -EOPNOTSUPP;
}
/* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */ /* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */
new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) & new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) &
......
...@@ -70,10 +70,10 @@ ...@@ -70,10 +70,10 @@
/* /*
* Version numbers * Version numbers
*/ */
#define VMXNET3_DRIVER_VERSION_STRING "1.1.29.0-k" #define VMXNET3_DRIVER_VERSION_STRING "1.1.30.0-k"
/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
#define VMXNET3_DRIVER_VERSION_NUM 0x01011D00 #define VMXNET3_DRIVER_VERSION_NUM 0x01011E00
#if defined(CONFIG_PCI_MSI) #if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */ /* RSS only makes sense if MSI-X is supported. */
......
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