aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomi Valkeinen2017-03-24 03:07:54 -0500
committerTomi Valkeinen2017-03-24 03:07:56 -0500
commit273494aa2d3836110d6a2c73c9e00503c711b01c (patch)
tree816673e9617f9414fea237f13e0a8d7b4b20ff79
parent2439ae8738ad9410441c6160f512ab64ec94333d (diff)
downloadexternal-libkmsxx-273494aa2d3836110d6a2c73c9e00503c711b01c.tar.gz
external-libkmsxx-273494aa2d3836110d6a2c73c9e00503c711b01c.tar.xz
external-libkmsxx-273494aa2d3836110d6a2c73c9e00503c711b01c.zip
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.cpp12
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)
101 101
102Connector* ResourceManager::reserve_connector(Connector* conn) 102Connector* ResourceManager::reserve_connector(Connector* conn)
103{ 103{
104 if (!conn)
105 return nullptr;
106
104 if (contains(m_reserved_connectors, conn)) 107 if (contains(m_reserved_connectors, conn))
105 return nullptr; 108 return nullptr;
106 109
@@ -110,6 +113,9 @@ Connector* ResourceManager::reserve_connector(Connector* conn)
110 113
111Crtc* ResourceManager::reserve_crtc(Connector* conn) 114Crtc* ResourceManager::reserve_crtc(Connector* conn)
112{ 115{
116 if (!conn)
117 return nullptr;
118
113 if (Crtc* crtc = conn->get_current_crtc()) { 119 if (Crtc* crtc = conn->get_current_crtc()) {
114 m_reserved_crtcs.push_back(crtc); 120 m_reserved_crtcs.push_back(crtc);
115 return crtc; 121 return crtc;
@@ -128,6 +134,9 @@ Crtc* ResourceManager::reserve_crtc(Connector* conn)
128 134
129Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format) 135Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat format)
130{ 136{
137 if (!crtc)
138 return nullptr;
139
131 for (Plane* plane : crtc->get_possible_planes()) { 140 for (Plane* plane : crtc->get_possible_planes()) {
132 if (plane->plane_type() == type) 141 if (plane->plane_type() == type)
133 continue; 142 continue;
@@ -147,6 +156,9 @@ Plane* ResourceManager::reserve_plane(Crtc* crtc, PlaneType type, PixelFormat fo
147 156
148Plane* ResourceManager::reserve_generic_plane(Crtc* crtc, PixelFormat format) 157Plane* ResourceManager::reserve_generic_plane(Crtc* crtc, PixelFormat format)
149{ 158{
159 if (!crtc)
160 return nullptr;
161
150 for (Plane* plane : crtc->get_possible_planes()) { 162 for (Plane* plane : crtc->get_possible_planes()) {
151 if (plane->plane_type() == PlaneType::Cursor) 163 if (plane->plane_type() == PlaneType::Cursor)
152 continue; 164 continue;