Skip to content

Commit 074bcc1

Browse files
djbwgregkh
authored andcommitted
acpi, nfit, libnvdimm: fix interleave set cookie calculation (64-bit comparison)
commit b03b99a329a14b7302f37c3ea6da3848db41c8c5 upstream. While reviewing the -stable patch for commit 86ef58a4e35e "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: Nicholas Moulin <nicholas.w.moulin@linux.intel.com> Fixes: 86ef58a4e35e ("nfit, libnvdimm: fix interleave set cookie calculation") Reported-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ec3978e commit 074bcc1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/acpi/nfit.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,11 @@ static int cmp_map(const void *m0, const void *m1)
979979
const struct nfit_set_info_map *map0 = m0;
980980
const struct nfit_set_info_map *map1 = m1;
981981

982-
return map0->region_offset - map1->region_offset;
982+
if (map0->region_offset < map1->region_offset)
983+
return -1;
984+
else if (map0->region_offset > map1->region_offset)
985+
return 1;
986+
return 0;
983987
}
984988

985989
/* Retrieve the nth entry referencing this spa */

0 commit comments

Comments
 (0)