Skip to content

Commit

Permalink
acpi, nfit, libnvdimm: fix interleave set cookie calculation (64-bit …
Browse files Browse the repository at this point in the history
…comparison)

While reviewing the -stable patch for commit 86ef58a "nfit,
libnvdimm: fix interleave set cookie calculation" Ben noted:

    "This is returning an int, thus it's effectively doing a 32-bit
     comparison and not the 64-bit comparison you say is needed."

Update the compare operation to be immune to this integer demotion problem.

Cc: <[email protected]>
Cc: Nicholas Moulin <[email protected]>
Fixes: 86ef58a ("nfit, libnvdimm: fix interleave set cookie calculation")
Reported-by: Ben Hutchings <[email protected]>
Signed-off-by: Dan Williams <[email protected]>
  • Loading branch information
djbw committed Mar 28, 2017
1 parent c02ed2e commit b03b99a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drivers/acpi/nfit/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,11 @@ static int cmp_map(const void *m0, const void *m1)
const struct nfit_set_info_map *map0 = m0;
const struct nfit_set_info_map *map1 = m1;

return map0->region_offset - map1->region_offset;
if (map0->region_offset < map1->region_offset)
return -1;
else if (map0->region_offset > map1->region_offset)
return 1;
return 0;
}

/* Retrieve the nth entry referencing this spa */
Expand Down

0 comments on commit b03b99a

Please sign in to comment.