aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira2012-07-27 05:30:51 -0500
committerSean Paul2015-04-17 15:16:24 -0500
commit34254f950699b1fa20c4f8d585cece0f15661249 (patch)
tree84f802ff7976ef828c9b773168e0817dfc52c19f /xf86drmMode.c
parentba5b0e9d9a3c894673b68b14cc82f53df32bbce8 (diff)
downloadexternal-libgbm-34254f950699b1fa20c4f8d585cece0f15661249.tar.gz
external-libgbm-34254f950699b1fa20c4f8d585cece0f15661249.tar.xz
external-libgbm-34254f950699b1fa20c4f8d585cece0f15661249.zip
BACKPORT: libdrm: Fix bogus increment of a property set object count
If drmModePropertySetAdd() is called with the following property pairs it will mistakenly increase the object count: (4, 1), (5,1), (4, 2). When adding the third pair, the new_obj variable would be set when prev points to (4, 1) since it disregarded the value of the previous item. This patch changes the logic so that the obj count is incresed only if both the previous and next items have differing object ids. (cherry picked from commit 2b1faf742b6391b1537e2635b6926b3a196c1540) Signed-off-by: Sean Paul <seanpaul@chromium.org>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 56762217..7f3bc5e8 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1174,10 +1174,8 @@ int drmModePropertySetAdd(drmModePropertySetPtr set,
1174 1174
1175 /* keep it sorted by object_id and property_id */ 1175 /* keep it sorted by object_id and property_id */
1176 while (prev->next) { 1176 while (prev->next) {
1177 if (prev->next->object_id > object_id) { 1177 if (prev->next->object_id > object_id)
1178 new_obj = true;
1179 break; 1178 break;
1180 }
1181 1179
1182 if (prev->next->object_id == object_id && 1180 if (prev->next->object_id == object_id &&
1183 prev->next->property_id >= property_id) 1181 prev->next->property_id >= property_id)
@@ -1186,8 +1184,8 @@ int drmModePropertySetAdd(drmModePropertySetPtr set,
1186 prev = prev->next; 1184 prev = prev->next;
1187 } 1185 }
1188 1186
1189 if (!prev->next && 1187 if ((prev == &set->list || prev->object_id != object_id) &&
1190 (prev == &set->list || prev->object_id != object_id)) 1188 (!prev->next || prev->next->object_id != object_id))
1191 new_obj = true; 1189 new_obj = true;
1192 1190
1193 /* replace or add? */ 1191 /* replace or add? */
@@ -1236,10 +1234,8 @@ int drmModePropertySetAddBlob(drmModePropertySetPtr set,
1236 1234
1237 /* keep it sorted by object_id and property_id */ 1235 /* keep it sorted by object_id and property_id */
1238 while (prev->next) { 1236 while (prev->next) {
1239 if (prev->next->object_id > object_id) { 1237 if (prev->next->object_id > object_id)
1240 new_obj = true;
1241 break; 1238 break;
1242 }
1243 1239
1244 if (prev->next->object_id == object_id && 1240 if (prev->next->object_id == object_id &&
1245 prev->next->property_id >= property_id) 1241 prev->next->property_id >= property_id)
@@ -1248,8 +1244,8 @@ int drmModePropertySetAddBlob(drmModePropertySetPtr set,
1248 prev = prev->next; 1244 prev = prev->next;
1249 } 1245 }
1250 1246
1251 if (!prev->next && 1247 if ((prev == &set->list || prev->object_id != object_id) &&
1252 (prev == &set->list || prev->object_id != object_id)) 1248 (!prev->next || prev->next->object_id != object_id))
1253 new_obj = true; 1249 new_obj = true;
1254 1250
1255 /* replace or add? */ 1251 /* replace or add? */