Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1d0620b in mainline


Ignore:
Timestamp:
2018-05-22T19:06:50Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
4e2d387
Parents:
1c40351
git-author:
Jakub Jermar <jakub@…> (2018-04-25 18:11:13)
git-committer:
Jakub Jermar <jakub@…> (2018-05-22 19:06:50)
Message:

Cleanup the device if initialization fails

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/virtio-net/virtio-net.c

    r1c40351 r1d0620b  
    8686
    8787        if (!features) {
    88                 pio_write_8(&cfg->device_status, VIRTIO_DEV_STATUS_FAILED);
    89                 return ENOTSUP;
     88                rc = ENOTSUP;
     89                goto fail;
    9090        }
    9191
     
    100100        uint8_t status = pio_read_8(&cfg->device_status);
    101101        if (!(status & VIRTIO_DEV_STATUS_FEATURES_OK)) {
    102                 pio_write_8(&cfg->device_status, VIRTIO_DEV_STATUS_FAILED);
    103                 return ENOTSUP;
     102                rc = ENOTSUP;
     103                goto fail;
    104104        }
    105105
     
    109109                nic_addr.address[i] = netcfg->mac[i];
    110110        rc = nic_report_address(nic_data, &nic_addr);
    111         if (rc != EOK) {
    112                 pio_write_8(&cfg->device_status, VIRTIO_DEV_STATUS_FAILED);
    113                 return rc;
    114         }
     111        if (rc != EOK)
     112                goto fail;
    115113
    116114        ddf_msg(LVL_NOTE, "MAC address: %02x:%02x:%02x:%02x:%02x:%02x",
    117             nic_addr.address[0], nic_addr.address[1],
    118             nic_addr.address[2], nic_addr.address[3],
    119             nic_addr.address[4], nic_addr.address[5]);
     115            nic_addr.address[0], nic_addr.address[1], nic_addr.address[2],
     116            nic_addr.address[3], nic_addr.address[4], nic_addr.address[5]);
    120117
    121118        /* 8. Go live */
     
    123120
    124121        return EOK;
     122
     123fail:
     124        pio_write_8(&cfg->device_status, VIRTIO_DEV_STATUS_FAILED);
     125        virtio_pci_dev_cleanup(&virtio_net->virtio_dev);
     126        return rc;
    125127}
    126128
  • uspace/lib/virtio/virtio-pci.c

    r1c40351 r1d0620b  
    244244}
    245245
     246errno_t virtio_pci_dev_cleanup(virtio_dev_t *vdev)
     247{
     248        return disable_resources(vdev);
     249}
     250
    246251/** @}
    247252 */
  • uspace/lib/virtio/virtio-pci.h

    r1c40351 r1d0620b  
    100100
    101101extern errno_t virtio_pci_dev_initialize(ddf_dev_t *, virtio_dev_t *);
     102extern errno_t virtio_pci_dev_cleanup(virtio_dev_t *);
    102103
    103104#endif
Note: See TracChangeset for help on using the changeset viewer.