Skip to content
Snippets Groups Projects
Commit 0bb5eee5 authored by Dor Laor's avatar Dor Laor
Browse files

Bug fix - do not access the bars on cleanup if the device wasn't present.

Longer term it should be nice not to allocate the bars at all
parent e4aba1d6
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,11 @@ bool Driver::isPresent() {
return _present;
}
Driver::~Driver() {
//todo - Better change the Bar allocation to live in the stack
for (int i=0;i<6;i++) if (_bars[i]) delete _bars[i];
}
void
Driver::setPresent(u8 bus, u8 slot, u8 func) {
_present = true;
......
......@@ -40,7 +40,7 @@ class Driver {
public:
Driver(u16 vid, u16 id) :_id(id), _vid(vid), _present(false), _bus(0), _slot(0), _func(0)\
{for (int i=0;i<6;i++) _bars[i] = nullptr;};
virtual ~Driver() {for (int i=0;i<6;i++) if (_bars[i]) delete _bars[i];}
virtual ~Driver();
bool isPresent();
void setPresent(u8 bus, u8 slot, u8 func);
......
......@@ -15,7 +15,6 @@ namespace virtio {
virtio_net::~virtio_net()
{
set_dev_status(0);
}
bool virtio_net::Init(Device *d)
......
......@@ -22,7 +22,6 @@ namespace virtio {
virtio_driver::~virtio_driver()
{
reset_host_side();
for (int i=0; i < max_virtqueues_nr; i++) {
if (NULL != _queues[i]) {
delete (_queues[i]);
......@@ -31,6 +30,8 @@ namespace virtio {
}
void virtio_driver::reset_host_side() {
if (!isPresent()) return;
set_dev_status(0);
pci_conf_write(VIRTIO_PCI_QUEUE_PFN,(u32)0);
}
......
......@@ -282,7 +282,7 @@ void* do_main_thread(void* pprog)
DeviceFactory::Instance()->InitializeDrivers();
//DriverFactory::Instance()->Destroy();
DriverFactory::Instance()->Destroy();
auto t1 = clock::get()->time();
auto t2 = clock::get()->time();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment