]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - drivers/scsi/sd.c
scsi: fix discard page leak
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Thu, 8 Jul 2010 08:16:17 +0000 (10:16 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Sat, 7 Aug 2010 16:24:28 +0000 (18:24 +0200)
commit610a63498f7f366031a6327eaaa9963ffa110b2b
tree8ea7f0c9e1e2f41ee09677909a3491adeee31799
parent9e094383b60066996fbc3b53891324e5d2ec858d
scsi: fix discard page leak

We leak a page allocated for discard on some error conditions
(e.g. scsi_prep_state_check returns BLKPREP_DEFER in
scsi_setup_blk_pc_cmnd).

We unprep on requests that weren't prepped in the error path of
scsi_init_io. It makes the error path to clean up scsi commands messy.

Let's strictly apply the rule that we can't unprep on a request that
wasn't prepped.

Calling just scsi_put_command() in the error path of scsi_init_io() is
enough. We don't set REQ_DONTPREP yet.

scsi_setup_discard_cmnd can safely free a page on the error case with
the above rule.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
drivers/scsi/scsi_lib.c
drivers/scsi/sd.c