Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95822
b: refs/heads/master
c: 9f5de6b
h: refs/heads/master
v: v3
  • Loading branch information
FUJITA Tomonori authored and James Bottomley committed May 2, 2008
1 parent 67b3c6f commit 1e35a6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0462590efe9a562dd2aa976ae2dc9cd2e6f5a0c6
refs/heads/master: 9f5de6b105bfa45911d46566df0b36720b648c42
12 changes: 9 additions & 3 deletions trunk/block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ static int bsg_io_schedule(struct bsg_device *bd)
static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
struct sg_io_v4 *hdr, int has_write_perm)
{
memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
if (hdr->request_len > BLK_MAX_CDB) {
rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
if (!rq->cmd)
return -ENOMEM;
}

if (copy_from_user(rq->cmd, (void *)(unsigned long)hdr->request,
hdr->request_len))
Expand Down Expand Up @@ -211,8 +215,6 @@ bsg_validate_sgv4_hdr(struct request_queue *q, struct sg_io_v4 *hdr, int *rw)

if (hdr->guard != 'Q')
return -EINVAL;
if (hdr->request_len > BLK_MAX_CDB)
return -EINVAL;
if (hdr->dout_xfer_len > (q->max_sectors << 9) ||
hdr->din_xfer_len > (q->max_sectors << 9))
return -EIO;
Expand Down Expand Up @@ -302,6 +304,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr)
}
return rq;
out:
if (rq->cmd != rq->__cmd)
kfree(rq->cmd);
blk_put_request(rq);
if (next_rq) {
blk_rq_unmap_user(next_rq->bio);
Expand Down Expand Up @@ -455,6 +459,8 @@ static int blk_complete_sgv4_hdr_rq(struct request *rq, struct sg_io_v4 *hdr,
ret = rq->errors;

blk_rq_unmap_user(bio);
if (rq->cmd != rq->__cmd)
kfree(rq->cmd);
blk_put_request(rq);

return ret;
Expand Down

0 comments on commit 1e35a6d

Please sign in to comment.