Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/test_hmm.c: handle src_pfns and dst_pfns allocation failure
[ Upstream commit c2af060 ] The kcalloc() in dmirror_device_evict_chunk() will return null if the physical memory has run out. As a result, if src_pfns or dst_pfns is dereferenced, the null pointer dereference bug will happen. Moreover, the device is going away. If the kcalloc() fails, the pages mapping a chunk could not be evicted. So add a __GFP_NOFAIL flag in kcalloc(). Finally, as there is no need to have physically contiguous memory, Switch kcalloc() to kvcalloc() in order to avoid failing allocations. Link: https://lkml.kernel.org/r/[email protected] Fixes: b2ef9f5 ("mm/hmm/test: add selftest driver for HMM") Signed-off-by: Duoming Zhou <[email protected]> Cc: Jérôme Glisse <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
- Loading branch information