[bug report] drm: kselftest for drm_mm and eviction

Dan Carpenter dan.carpenter at oracle.com
Tue Jan 10 14:17:46 UTC 2017


Hello Chris Wilson,

The patch 560b32842912: "drm: kselftest for drm_mm and eviction" from
Dec 22, 2016, leads to the following static checker warning:

	drivers/gpu/drm/selftests/test-drm_mm.c:1277 evict_everything()
	warn: calling list_del() inside list_for_each

drivers/gpu/drm/selftests/test-drm_mm.c
  1260  static bool evict_everything(struct drm_mm *mm,
  1261                               unsigned int total_size,
  1262                               struct evict_node *nodes)
  1263  {
  1264          struct drm_mm_scan scan;
  1265          LIST_HEAD(evict_list);
  1266          struct evict_node *e;
  1267          unsigned int n;
  1268          int err;
  1269  
  1270          drm_mm_scan_init(&scan, mm, total_size, 0, 0, 0);
  1271          for (n = 0; n < total_size; n++) {
  1272                  e = &nodes[n];
  1273                  list_add(&e->link, &evict_list);
  1274                  if (drm_mm_scan_add_block(&scan, &e->node))
  1275                          break;
  1276          }
  1277          list_for_each_entry(e, &evict_list, link) {
  1278                  if (!drm_mm_scan_remove_block(&scan, &e->node)) {
  1279                          pr_err("Node %lld not marked for eviction!\n",
  1280                                 e->node.start);
  1281                          list_del(&e->link);

Probably this should be using list_for_each_entry_safe(), I guess?

  1282                  }
  1283          }
  1284  
  1285          list_for_each_entry(e, &evict_list, link)
  1286                  drm_mm_remove_node(&e->node);
  1287  
  1288          if (!assert_one_hole(mm, 0, total_size))
  1289                  return false;
  1290  
  1291          list_for_each_entry(e, &evict_list, link) {
  1292                  err = drm_mm_reserve_node(mm, &e->node);
  1293                  if (err) {
  1294                          pr_err("Failed to reinsert node after eviction: start=%llx\n",
  1295                                 e->node.start);
  1296                          return false;
  1297                  }
  1298          }
  1299  
  1300          return assert_continuous(mm, nodes[0].node.size);
  1301  }

regards,
dan carpenter


More information about the dri-devel mailing list