diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-03-24 10:07:54 +0200 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2017-03-24 10:07:56 +0200 |
commit | 273494aa2d3836110d6a2c73c9e00503c711b01c (patch) | |
tree | 816673e9617f9414fea237f13e0a8d7b4b20ff79 | |
parent | 2439ae8738ad9410441c6160f512ab64ec94333d (diff) |
resmgr: add sanity checks
Add sanity checks to reserve_* methods, and return null if the give
connector/crtc is null.
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r-- | kms++util/src/resourcemanager.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/kms++util/src/resourcemanager.cpp b/kms++util/src/resourcemanager.cpp index 23a1480..f751147 100644 --- a/kms++util/src/resourcemanager.cpp +++ b/kms++util/src/resourcemanager.cpp @@ -101,6 +101,9 @@ Connector* ResourceManager::reserve_connector(const string& name) Connector* ResourceManager::reserve_connector(Connector* conn) { + if (!conn) + return nullptr; + if (contains(m_reserved_connectors, conn)) return nullptr; @@ -110,6 +113,9 @@ Connector* ResourceManager::reserve_connector(Connector* conn) Crtc* ResourceManager::reserve_crtc(Connector* conn) { + if (!conn) + return nullptr; + if (Crtc* crtc = conn->get_current_crtc()) { m_reserved_crtcs.push_back(crtc); return crtc; @@ -128,6 +134,9 @@ Crtc* ResourceManager::reserve_crtc(Connector* conn) Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format) { + if (!crtc) + return nullptr; + for (Plane* plane : crtc->get_possible_planes()) { if (plane->plane_type() == type) continue; @@ -147,6 +156,9 @@ Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat fo Plane* ResourceManager::reserve_generic_plane(Crtc* crtc, PixelFormat format) { + if (!crtc) + return nullptr; + for (Plane* plane : crtc->get_possible_planes()) { if (plane->plane_type() == PlaneType::Cursor) continue; |