hw: de-reference deleted kernel objects

Fix #2591
This commit is contained in:
Stefan Kalkowski 2017-11-28 15:59:07 +01:00 committed by Christian Helmuth
parent f68be31fa3
commit d1e0e460a1
2 changed files with 8 additions and 4 deletions

View File

@ -26,12 +26,16 @@ void Object_identity::invalidate()
{ {
for (Object_identity_reference * oir = first(); oir; oir = first()) for (Object_identity_reference * oir = first(); oir; oir = first())
oir->invalidate(); oir->invalidate();
_object.remove(this);
if (_object) {
_object->remove(this);
_object = nullptr;
}
} }
Object_identity::Object_identity(Object & object) Object_identity::Object_identity(Object & object)
: _object(object) { _object.insert(this); } : _object(&object) { _object->insert(this); }
Object_identity::~Object_identity() { invalidate(); } Object_identity::~Object_identity() { invalidate(); }

View File

@ -83,7 +83,7 @@ class Kernel::Object_identity
{ {
private: private:
Object & _object; Object * _object = nullptr;
public: public:
@ -91,7 +91,7 @@ class Kernel::Object_identity
~Object_identity(); ~Object_identity();
template <typename KOBJECT> template <typename KOBJECT>
KOBJECT * object() { return dynamic_cast<KOBJECT*>(&_object); } KOBJECT * object() { return dynamic_cast<KOBJECT*>(_object); }
void invalidate(); void invalidate();
}; };