]> git.baikalelectronics.ru Git - kernel.git/commit
nfit_test: fix buffer overrun, add sanity check
authorRoss Zwisler <ross.zwisler@linux.intel.com>
Tue, 27 Feb 2018 17:29:51 +0000 (10:29 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 6 Mar 2018 19:05:37 +0000 (11:05 -0800)
commit0fe6f5ae38d4977ad335b56b9333629d8d88481a
treeab66750172619c8af0d38aeb85e60c6e8bcf84f2
parent62f28984a11c91e5da413db779ff3e34d61b83ba
nfit_test: fix buffer overrun, add sanity check

It turns out that we were overrunning the 'nfit_buf' buffer in
nfit_test0_setup() in the (t->setup_hotplug == 1) case because we failed to
correctly account for all of the acpi_nfit_memory_map structures.

Fix the structure count which will increase the allocation size of
'nfit_buf' in nfit_test0_alloc().  Also add some WARN_ON()s to
nfit_test0_setup() and nfit_test1_setup() to catch future issues where the
size of the buffer doesn't match the amount of data we're writing.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
tools/testing/nvdimm/test/nfit.c