diff options
Diffstat (limited to 'block')
-rw-r--r-- | block/bsg.c | 12 | ||||
-rw-r--r-- | block/scsi_ioctl.c | 5 |
2 files changed, 11 insertions, 6 deletions
diff --git a/block/bsg.c b/block/bsg.c index fa796b605f55..f0b7cd343216 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -174,7 +174,11 @@ unlock: | |||
174 | static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq, | 174 | static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq, |
175 | struct sg_io_v4 *hdr, int has_write_perm) | 175 | struct sg_io_v4 *hdr, int has_write_perm) |
176 | { | 176 | { |
177 | memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ | 177 | if (hdr->request_len > BLK_MAX_CDB) { |
178 | rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL); | ||
179 | if (!rq->cmd) | ||
180 | return -ENOMEM; | ||
181 | } | ||
178 | 182 | ||
179 | if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request, | 183 | if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request, |
180 | hdr->request_len)) | 184 | hdr->request_len)) |
@@ -211,8 +215,6 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw) | |||
211 | 215 | ||
212 | if (hdr->guard != 'Q') | 216 | if (hdr->guard != 'Q') |
213 | return -EINVAL; | 217 | return -EINVAL; |
214 | if (hdr->request_len > BLK_MAX_CDB) | ||
215 | return -EINVAL; | ||
216 | if (hdr->dout_xfer_len > (q->max_sectors << 9) || | 218 | if (hdr->dout_xfer_len > (q->max_sectors << 9) || |
217 | hdr->din_xfer_len > (q->max_sectors << 9)) | 219 | hdr->din_xfer_len > (q->max_sectors << 9)) |
218 | return -EIO; | 220 | return -EIO; |
@@ -302,6 +304,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr) | |||
302 | } | 304 | } |
303 | return rq; | 305 | return rq; |
304 | out: | 306 | out: |
307 | if (rq->cmd != rq->__cmd) | ||
308 | kfree(rq->cmd); | ||
305 | blk_put_request(rq); | 309 | blk_put_request(rq); |
306 | if (next_rq) { | 310 | if (next_rq) { |
307 | blk_rq_unmap_user(next_rq->bio); | 311 | blk_rq_unmap_user(next_rq->bio); |
@@ -455,6 +459,8 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr, | |||
455 | ret = rq->errors; | 459 | ret = rq->errors; |
456 | 460 | ||
457 | blk_rq_unmap_user(bio); | 461 | blk_rq_unmap_user(bio); |
462 | if (rq->cmd != rq->__cmd) | ||
463 | kfree(rq->cmd); | ||
458 | blk_put_request(rq); | 464 | blk_put_request(rq); |
459 | 465 | ||
460 | return ret; | 466 | return ret; |
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index ffa3720e6ca0..78199c08ec92 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -33,13 +33,12 @@ | |||
33 | #include <scsi/scsi_cmnd.h> | 33 | #include <scsi/scsi_cmnd.h> |
34 | 34 | ||
35 | /* Command group 3 is reserved and should never be used. */ | 35 | /* Command group 3 is reserved and should never be used. */ |
36 | const unsigned char scsi_command_size[8] = | 36 | const unsigned char scsi_command_size_tbl[8] = |
37 | { | 37 | { |
38 | 6, 10, 10, 12, | 38 | 6, 10, 10, 12, |
39 | 16, 12, 10, 10 | 39 | 16, 12, 10, 10 |
40 | }; | 40 | }; |
41 | 41 | EXPORT_SYMBOL(scsi_command_size_tbl); | |
42 | EXPORT_SYMBOL(scsi_command_size); | ||
43 | 42 | ||
44 | #include <scsi/sg.h> | 43 | #include <scsi/sg.h> |
45 | 44 | ||