提交 7c1885ae 编写于 作者: N Nathan Fontenot 提交者: David S. Miller

ibmvnic: Clean up resources on probe failure

Ensure that any resources allocated during probe are released if the
probe of the driver fails.
Signed-off-by: NNathan Fontenot <nfont@linux.vnet.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 cd9cb389
...@@ -3841,31 +3841,35 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id) ...@@ -3841,31 +3841,35 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
do { do {
rc = ibmvnic_init(adapter); rc = ibmvnic_init(adapter);
if (rc && rc != EAGAIN) { if (rc && rc != EAGAIN)
free_netdev(netdev); goto ibmvnic_init_fail;
return rc;
}
} while (rc == EAGAIN); } while (rc == EAGAIN);
netdev->mtu = adapter->req_mtu - ETH_HLEN; netdev->mtu = adapter->req_mtu - ETH_HLEN;
rc = device_create_file(&dev->dev, &dev_attr_failover); rc = device_create_file(&dev->dev, &dev_attr_failover);
if (rc) { if (rc)
free_netdev(netdev); goto ibmvnic_init_fail;
return rc;
}
rc = register_netdev(netdev); rc = register_netdev(netdev);
if (rc) { if (rc) {
dev_err(&dev->dev, "failed to register netdev rc=%d\n", rc); dev_err(&dev->dev, "failed to register netdev rc=%d\n", rc);
device_remove_file(&dev->dev, &dev_attr_failover); goto ibmvnic_register_fail;
free_netdev(netdev);
return rc;
} }
dev_info(&dev->dev, "ibmvnic registered\n"); dev_info(&dev->dev, "ibmvnic registered\n");
adapter->state = VNIC_PROBED; adapter->state = VNIC_PROBED;
return 0; return 0;
ibmvnic_register_fail:
device_remove_file(&dev->dev, &dev_attr_failover);
ibmvnic_init_fail:
release_sub_crqs(adapter);
release_crq_queue(adapter);
free_netdev(netdev);
return rc;
} }
static int ibmvnic_remove(struct vio_dev *dev) static int ibmvnic_remove(struct vio_dev *dev)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册