summaryrefslogtreecommitdiff
path: root/drivers/block/xen-blkfront.c
diff options
context:
space:
mode:
authorFelipe Pena <felipensp@gmail.com>2013-11-09 19:36:09 +0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2013-11-26 20:24:01 +0400
commit2f089cb89d2f47702c31bd584c12badc88bbe17c (patch)
tree3041158a5ba7d03f4f4f93197c86095794a585b6 /drivers/block/xen-blkfront.c
parent427bfe07e6744c058ce6fc4aa187cda96b635539 (diff)
downloadlinux-2f089cb89d2f47702c31bd584c12badc88bbe17c.tar.xz
block: xen-blkfront: Fix possible NULL ptr dereference
In the blkif_release function the bdget_disk() call might returns a NULL ptr which might be dereferenced on bdev->bd_openers checking Signed-off-by: Felipe Pena <felipensp@gmail.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> [v2: Added WARN per Roger's suggestion]
Diffstat (limited to 'drivers/block/xen-blkfront.c')
-rw-r--r--drivers/block/xen-blkfront.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index 5f926de61950..c4a4c9006288 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2011,6 +2011,10 @@ static void blkif_release(struct gendisk *disk, fmode_t mode)
bdev = bdget_disk(disk, 0);
+ if (!bdev) {
+ WARN(1, "Block device %s yanked out from us!\n", disk->disk_name);
+ goto out_mutex;
+ }
if (bdev->bd_openers)
goto out;
@@ -2041,6 +2045,7 @@ static void blkif_release(struct gendisk *disk, fmode_t mode)
out:
bdput(bdev);
+out_mutex:
mutex_unlock(&blkfront_mutex);
}