[bug report] mm, compaction: capture a page under direct compaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Mel Gorman,

This is a semi-automatic email about new static checker warnings.

The patch 5e1f0f098b46: "mm, compaction: capture a page under direct 
compaction" from Mar 5, 2019, leads to the following Smatch complaint:

    mm/compaction.c:2321 compact_zone_order()
     error: we previously assumed 'capture' could be null (see line 2313)

mm/compaction.c
  2288  static enum compact_result compact_zone_order(struct zone *zone, int order,
  2289                  gfp_t gfp_mask, enum compact_priority prio,
  2290                  unsigned int alloc_flags, int classzone_idx,
  2291                  struct page **capture)
                                      ^^^^^^^
  2292  {
  2293          enum compact_result ret;
  2294          struct compact_control cc = {
  2295                  .order = order,
  2296                  .search_order = order,
  2297                  .gfp_mask = gfp_mask,
  2298                  .zone = zone,
  2299                  .mode = (prio == COMPACT_PRIO_ASYNC) ?
  2300                                          MIGRATE_ASYNC : MIGRATE_SYNC_LIGHT,
  2301                  .alloc_flags = alloc_flags,
  2302                  .classzone_idx = classzone_idx,
  2303                  .direct_compaction = true,
  2304                  .whole_zone = (prio == MIN_COMPACT_PRIORITY),
  2305                  .ignore_skip_hint = (prio == MIN_COMPACT_PRIORITY),
  2306                  .ignore_block_suitable = (prio == MIN_COMPACT_PRIORITY)
  2307          };
  2308          struct capture_control capc = {
  2309                  .cc = &cc,
  2310                  .page = NULL,
  2311          };
  2312	
  2313		if (capture)
                    ^^^^^^^
Check for NULL

  2314			current->capture_control = &capc;
  2315	
  2316		ret = compact_zone(&cc, &capc);
  2317	
  2318		VM_BUG_ON(!list_empty(&cc.freepages));
  2319		VM_BUG_ON(!list_empty(&cc.migratepages));
  2320	
  2321		*capture = capc.page;
                ^^^^^^^^
Unchecked dereference.

  2322		current->capture_control = NULL;
  2323	

regards,
dan carpenter




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux