提交 4df38926 编写于 作者: R Richard Weinberger 提交者: Artem Bityutskiy

UBI: block: Avoid disk size integer overflow

This patch fixes the issue that on very large UBI volumes
UBI block does not work correctly.
Signed-off-by: NRichard Weinberger <richard@nod.at>
Signed-off-by: NEzequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: NArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
上级 0a3d571b
......@@ -378,9 +378,11 @@ int ubiblock_create(struct ubi_volume_info *vi)
{
struct ubiblock *dev;
struct gendisk *gd;
int disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
u64 disk_capacity = ((u64)vi->size * vi->usable_leb_size) >> 9;
int ret;
if ((sector_t)disk_capacity != disk_capacity)
return -EFBIG;
/* Check that the volume isn't already handled */
mutex_lock(&devices_mutex);
if (find_dev_nolock(vi->ubi_num, vi->vol_id)) {
......@@ -500,8 +502,13 @@ int ubiblock_remove(struct ubi_volume_info *vi)
static int ubiblock_resize(struct ubi_volume_info *vi)
{
struct ubiblock *dev;
int disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
u64 disk_capacity = ((u64)vi->size * vi->usable_leb_size) >> 9;
if ((sector_t)disk_capacity != disk_capacity) {
ubi_warn("%s: the volume is too big, cannot resize (%d LEBs)",
dev->gd->disk_name, vi->size);
return -EFBIG;
}
/*
* Need to lock the device list until we stop using the device,
* otherwise the device struct might get released in
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册