diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2014-02-26 08:57:01 -0500 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2014-03-19 15:15:03 -0400 |
commit | c5af0db96b7c219245f4985314e11c7e716e82ae (patch) | |
tree | be49e665ebc69510453172300f112503905c56ad | |
parent | c613d061ce01be1f4e195f4666d4a99e5284cb5d (diff) |
[SCSI] scsi_debug: fix resp_xdwriteread() return value when running out of memory
When resp_xdwriteread() can't allocate temporary buffer, it returns -1.
But the return value is used as scsi status code and -1 is not
interpreted as correct code.
target_core_mod has similar xdwriteread emulation code. So this mimics
what target_core_mod does for xdwriteread when running out of memory.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Reviewed-by: Douglas Gilbert <dgilbert@interlog.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | drivers/scsi/scsi_debug.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 1a4288032110..a10251908875 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
@@ -64,6 +64,7 @@ static const char * scsi_debug_version_date = "20100324"; | |||
64 | /* Additional Sense Code (ASC) */ | 64 | /* Additional Sense Code (ASC) */ |
65 | #define NO_ADDITIONAL_SENSE 0x0 | 65 | #define NO_ADDITIONAL_SENSE 0x0 |
66 | #define LOGICAL_UNIT_NOT_READY 0x4 | 66 | #define LOGICAL_UNIT_NOT_READY 0x4 |
67 | #define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8 | ||
67 | #define UNRECOVERED_READ_ERR 0x11 | 68 | #define UNRECOVERED_READ_ERR 0x11 |
68 | #define PARAMETER_LIST_LENGTH_ERR 0x1a | 69 | #define PARAMETER_LIST_LENGTH_ERR 0x1a |
69 | #define INVALID_OPCODE 0x20 | 70 | #define INVALID_OPCODE 0x20 |
@@ -2318,8 +2319,11 @@ static int resp_xdwriteread(struct scsi_cmnd *scp, unsigned long long lba, | |||
2318 | 2319 | ||
2319 | /* better not to use temporary buffer. */ | 2320 | /* better not to use temporary buffer. */ |
2320 | buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); | 2321 | buf = kmalloc(scsi_bufflen(scp), GFP_ATOMIC); |
2321 | if (!buf) | 2322 | if (!buf) { |
2322 | return ret; | 2323 | mk_sense_buffer(devip, NOT_READY, |
2324 | LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); | ||
2325 | return check_condition_result; | ||
2326 | } | ||
2323 | 2327 | ||
2324 | scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); | 2328 | scsi_sg_copy_to_buffer(scp, buf, scsi_bufflen(scp)); |
2325 | 2329 | ||