aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmil Velikov2015-09-05 11:20:53 -0500
committerEmil Velikov2015-09-21 11:32:03 -0500
commited3c665548c2c0400a7e9e91cb9324c9e1f29375 (patch)
tree3c528e88f014dd647ba4f8c7ccf04984a52ed80a /xf86drmMode.c
parent00808a99d05929f675bb4ab680a1ffc6d0868ba4 (diff)
downloadexternal-libgbm-ed3c665548c2c0400a7e9e91cb9324c9e1f29375.tar.gz
external-libgbm-ed3c665548c2c0400a7e9e91cb9324c9e1f29375.tar.xz
external-libgbm-ed3c665548c2c0400a7e9e91cb9324c9e1f29375.zip
xf86drmMode: smoke-test the atomic API
As going through the modetest patches for atomic support I've noticed that if we pass NULL for the drmModeAtomicReqPtr argument we'll crash. So let's handle things appropriately if the user forgot to check the return value of drmModeAtomicAlloc and drmModeAtomicDuplicate or made a typo somewhere along the way. Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Rob Clark <robclark@freedesktop.org> Cc: Daniel Stone <daniels@collabora.com> Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 23800dd1..ab6b5195 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1189,6 +1189,9 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
1189{ 1189{
1190 drmModeAtomicReqPtr new; 1190 drmModeAtomicReqPtr new;
1191 1191
1192 if (!old)
1193 return NULL;
1194
1192 new = drmMalloc(sizeof *new); 1195 new = drmMalloc(sizeof *new);
1193 if (!new) 1196 if (!new)
1194 return NULL; 1197 return NULL;
@@ -1213,6 +1216,9 @@ drmModeAtomicReqPtr drmModeAtomicDuplicate(drmModeAtomicReqPtr old)
1213 1216
1214int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment) 1217int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
1215{ 1218{
1219 if (!base)
1220 return -EINVAL;
1221
1216 if (!augment || augment->cursor == 0) 1222 if (!augment || augment->cursor == 0)
1217 return 0; 1223 return 0;
1218 1224
@@ -1239,12 +1245,15 @@ int drmModeAtomicMerge(drmModeAtomicReqPtr base, drmModeAtomicReqPtr augment)
1239 1245
1240int drmModeAtomicGetCursor(drmModeAtomicReqPtr req) 1246int drmModeAtomicGetCursor(drmModeAtomicReqPtr req)
1241{ 1247{
1248 if (!req)
1249 return -EINVAL;
1242 return req->cursor; 1250 return req->cursor;
1243} 1251}
1244 1252
1245void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor) 1253void drmModeAtomicSetCursor(drmModeAtomicReqPtr req, int cursor)
1246{ 1254{
1247 req->cursor = cursor; 1255 if (req)
1256 req->cursor = cursor;
1248} 1257}
1249 1258
1250int drmModeAtomicAddProperty(drmModeAtomicReqPtr req, 1259int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
@@ -1252,6 +1261,9 @@ int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
1252 uint32_t property_id, 1261 uint32_t property_id,
1253 uint64_t value) 1262 uint64_t value)
1254{ 1263{
1264 if (!req)
1265 return -EINVAL;
1266
1255 if (req->cursor >= req->size_items) { 1267 if (req->cursor >= req->size_items) {
1256 drmModeAtomicReqItemPtr new; 1268 drmModeAtomicReqItemPtr new;
1257 1269
@@ -1309,6 +1321,9 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
1309 int obj_idx = -1; 1321 int obj_idx = -1;
1310 int ret = -1; 1322 int ret = -1;
1311 1323
1324 if (!req)
1325 return -EINVAL;
1326
1312 if (req->cursor == 0) 1327 if (req->cursor == 0)
1313 return 0; 1328 return 0;
1314 1329