Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7048538e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "block: Fix use-after-free in blkdev_get()"

parents 637e4cea 7d8cd031
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -1286,11 +1286,9 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
	 */
	if (!for_part) {
		ret = devcgroup_inode_permission(bdev->bd_inode, perm);
		if (ret != 0) {
			bdput(bdev);
		if (ret != 0)
			return ret;
	}
	}

 restart:

@@ -1361,8 +1359,10 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
				goto out_clear;
			BUG_ON(for_part);
			ret = __blkdev_get(whole, mode, 1);
			if (ret)
			if (ret) {
				bdput(whole);
				goto out_clear;
			}
			bdev->bd_contains = whole;
			bdev->bd_part = disk_get_part(disk, partno);
			if (!(disk->flags & GENHD_FL_UP) ||
@@ -1416,7 +1416,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
	put_disk(disk);
	module_put(owner);
 out:
	bdput(bdev);

	return ret;
}
@@ -1502,6 +1501,9 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
		bdput(whole);
	}

	if (res)
		bdput(bdev);

	return res;
}
EXPORT_SYMBOL(blkdev_get);