NVMe: Handle failures from memory allocations in nvme_setup_prps
authorMatthew Wilcox <matthew.r.wilcox@intel.com>
Thu, 12 May 2011 17:51:41 +0000 (13:51 -0400)
committerMatthew Wilcox <matthew.r.wilcox@intel.com>
Fri, 4 Nov 2011 19:53:03 +0000 (15:53 -0400)
commitb77954cbddff28d55a36fad3c16f4daebb0f01df
tree94f992d9c3390b61e11209f7b0e31440f67ec9c4
parent5aff9382ddc8aac6eb0c70ffbb351652d71da69a
NVMe: Handle failures from memory allocations in nvme_setup_prps

If any of the memory allocations in nvme_setup_prps fail, handle it by
modifying the passed-in data length to reflect the number of bytes we are
actually able to send.  Also allow the caller to specify the GFP flags
they need; for user-initiated commands, we can use GFP_KERNEL allocations.

The various callers are updated to handle this possibility; the main
I/O path is already prepared for this possibility (as it may happen
due to nvme_map_bio being unable to map all the segments of the I/O).
The other callers return -ENOMEM instead of doing partial I/Os.

Reported-by: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
drivers/block/nvme.c