Author: mw Date: Thu May 30 13:24:47 2019 New Revision: 348399 URL: https://svnweb.freebsd.org/changeset/base/348399
Log: Change attach order to prevent crash upon failure in ENA The if_detach was causing crash if the MSI-x configuration in the attach failed. To prevent this issue, the ifnet is being configured at the end of the attach function. Submitted by: Michal Krawczyk <m...@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon, Inc. Modified: head/sys/dev/ena/ena.c Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Thu May 30 13:22:53 2019 (r348398) +++ head/sys/dev/ena/ena.c Thu May 30 13:24:47 2019 (r348399) @@ -3819,18 +3819,18 @@ ena_attach(device_t pdev) device_printf(pdev, "initalize %d io queues\n", io_queue_num); ena_init_io_rings(adapter); - /* setup network interface */ - rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx); + rc = ena_enable_msix_and_set_admin_interrupts(adapter, io_queue_num); if (unlikely(rc != 0)) { - device_printf(pdev, "Error with network interface setup\n"); + device_printf(pdev, + "Failed to enable and set the admin interrupts\n"); goto err_io_free; } - rc = ena_enable_msix_and_set_admin_interrupts(adapter, io_queue_num); + /* setup network interface */ + rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx); if (unlikely(rc != 0)) { - device_printf(pdev, - "Failed to enable and set the admin interrupts\n"); - goto err_ifp_free; + device_printf(pdev, "Error with network interface setup\n"); + goto err_msix_free; } /* Initialize reset task queue */ @@ -3853,9 +3853,10 @@ ena_attach(device_t pdev) adapter->running = true; return (0); -err_ifp_free: - if_detach(adapter->ifp); - if_free(adapter->ifp); +err_msix_free: + ena_com_dev_reset(adapter->ena_dev, ENA_REGS_RESET_INIT_ERR); + ena_free_mgmnt_irq(adapter); + ena_disable_msix(adapter); err_io_free: ena_free_all_io_rings_resources(adapter); ena_free_rx_dma_tag(adapter); _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"