diff options
author | Vegard Nossum <vegard.nossum@oracle.com> | 2013-09-05 07:00:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-04 13:56:25 -0500 |
commit | d0ac18ce1a3d607ad650fd4b9d371be75a5c8e3a (patch) | |
tree | 1e55191247006b44fa06f447a692e83e51722988 | |
parent | ef0d74867fc7e440b0e945e7fe47a862dbc9c9ef (diff) |
xen/blkback: fix reference counting
commit ea5ec76d76da9279d12027c1828544c5ccbe7932 upstream.
If the permission check fails, we drop a reference to the blkif without
having taken it in the first place. The bug was introduced in commit
604c499cbbcc3d5fe5fb8d53306aa0fae1990109 (xen/blkback: Check device
permissions before allowing OP_DISCARD).
Cc: Jan Beulich <JBeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/block/xen-blkback/blkback.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c index d81dfca755d1..03dd4aa612db 100644 --- a/drivers/block/xen-blkback/blkback.c +++ b/drivers/block/xen-blkback/blkback.c | |||
@@ -649,6 +649,8 @@ static int dispatch_discard_io(struct xen_blkif *blkif, | |||
649 | unsigned long secure; | 649 | unsigned long secure; |
650 | struct phys_req preq; | 650 | struct phys_req preq; |
651 | 651 | ||
652 | xen_blkif_get(blkif); | ||
653 | |||
652 | preq.sector_number = req->u.discard.sector_number; | 654 | preq.sector_number = req->u.discard.sector_number; |
653 | preq.nr_sects = req->u.discard.nr_sectors; | 655 | preq.nr_sects = req->u.discard.nr_sectors; |
654 | 656 | ||
@@ -661,7 +663,6 @@ static int dispatch_discard_io(struct xen_blkif *blkif, | |||
661 | } | 663 | } |
662 | blkif->st_ds_req++; | 664 | blkif->st_ds_req++; |
663 | 665 | ||
664 | xen_blkif_get(blkif); | ||
665 | secure = (blkif->vbd.discard_secure && | 666 | secure = (blkif->vbd.discard_secure && |
666 | (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ? | 667 | (req->u.discard.flag & BLKIF_DISCARD_SECURE)) ? |
667 | BLKDEV_DISCARD_SECURE : 0; | 668 | BLKDEV_DISCARD_SECURE : 0; |