block: xen-blkfront: Fix possible NULL ptr dereference
Subsystems (3)
PATCH 1/1 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
--- drivers/block/xen-blkfront.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/block/xen-blkfront.c +4 -0
@@ -1959,6 +1959,9 @@ static void blkif_release(struct gendisk *disk, fmode_t mode) bdev =bdget_disk (disk,0 ); +if (!bdev) + goto out_mutex; +if (bdev->bd_openers) goto out;
@@ -1989,6 +1992,7 @@ static void blkif_release(struct gendisk *disk, fmode_t mode) out:bdput (bdev); +out_mutex:mutex_unlock (&blkfront_mutex); }
Signature · 1 line
1.7.10.4
Quoted 13 lines · Felipe Pena
In the
blkif_releasefunction thebdget_disk()call might returns a NULL ptr which might be dereferenced onbdev->bd_openerscheckingSigned-off-by Felipe Pena <[email protected]>--- drivers/block/xen-blkfront.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/block/xen-blkfront.c +0
-0
drivers/block/xen-blkfront.c static void blkif_release(struct gendisk *disk, fmode_t mode) · line 1963
Quoted 5 lines
drivers/block/xen-blkfront.c +2
-0@@ -1959,6 +1959,9 @@ static void blkif_release(struct gendisk *disk, fmode_t mode) bdev =bdget_disk (disk,0 ); +if (!bdev) + goto out_mutex;
Is this actually possible? By looking at blkfront code, it seems like we don't remove the device if it is still open, so maybe this should be a BUG_ON instead of failing silently.
Roger.
Quoted 13 lines · Felipe Pena
In the
blkif_releasefunction thebdget_disk()call might returns a NULL ptr which might be dereferenced onbdev->bd_openerscheckingSigned-off-by Felipe Pena <[email protected]>--- drivers/block/xen-blkfront.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/block/xen-blkfront.c +0
-0
drivers/block/xen-blkfront.c static void blkif_release(struct gendisk *disk, fmode_t mode) · line 1963
Quoted 5 lines
drivers/block/xen-blkfront.c +2
-0@@ -1959,6 +1959,9 @@ static void blkif_release(struct gendisk *disk, fmode_t mode) bdev =bdget_disk (disk,0 ); +if (!bdev) + goto out_mutex;
Is this actually possible? By looking at blkfront code, it seems like we don't remove the device if it is still open, so maybe this should be a BUG_ON instead of failing silently.
Roger.