Skip to content

Commit

Permalink
scsi: Fix more error handling in SCSI_IOCTL_SEND_COMMAND
Browse files Browse the repository at this point in the history
Fix an error path in SCSI_IOCTL_SEND_COMMAND that calls
blk_put_request(rq) on an invalid IS_ERR(rq) pointer.

Fixes: a492f07 ("block,scsi: fixup blk_get_request dead queue scenarios")
Signed-off-by: Tony Battersby <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
abattersby authored and axboe committed Nov 10, 2014
1 parent f3af020 commit 92697dc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
if (IS_ERR(rq)) {
err = PTR_ERR(rq);
goto error;
goto error_free_buffer;
}
blk_rq_set_block_pc(rq);

Expand Down Expand Up @@ -531,9 +531,11 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
}

error:
blk_put_request(rq);

error_free_buffer:
kfree(buffer);
if (rq)
blk_put_request(rq);

return err;
}
EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
Expand Down

0 comments on commit 92697dc

Please sign in to comment.