Merge tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull more overflow updates from Kees Cook: "The rest of the overflow changes for v4.18-rc1. This includes the explicit overflow fixes from Silvio, further struct_size() conversions from Matthew, and a bug fix from Dan. But the bulk of it is the treewide conversions to use either the 2-factor argument allocators (e.g. kmalloc(a * b, ...) into kmalloc_array(a, b, ...) or the array_size() macros (e.g. vmalloc(a * b) into vmalloc(array_size(a, b)). Coccinelle was fighting me on several fronts, so I've done a bunch of manual whitespace updates in the patches as well. Summary: - Error path bug fix for overflow tests (Dan) - Additional struct_size() conversions (Matthew, Kees) - Explicitly reported overflow fixes (Silvio, Kees) - Add missing kvcalloc() function (Kees) - Treewide conversions of allocators to use either 2-factor argument variant when available, or array_size() and array3_size() as needed (Kees)" * tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (26 commits) treewide: Use array_size in f2fs_kvzalloc() treewide: Use array_size() in f2fs_kzalloc() treewide: Use array_size() in f2fs_kmalloc() treewide: Use array_size() in sock_kmalloc() treewide: Use array_size() in kvzalloc_node() treewide: Use array_size() in vzalloc_node() treewide: Use array_size() in vzalloc() treewide: Use array_size() in vmalloc() treewide: devm_kzalloc() -> devm_kcalloc() treewide: devm_kmalloc() -> devm_kmalloc_array() treewide: kvzalloc() -> kvcalloc() treewide: kvmalloc() -> kvmalloc_array() treewide: kzalloc_node() -> kcalloc_node() treewide: kzalloc() -> kcalloc() treewide: kmalloc() -> kmalloc_array() mm: Introduce kvcalloc() video: uvesafb: Fix integer overflow in allocation UBIFS: Fix potential integer overflow in allocation leds: Use struct_size() in allocation Convert intel uncore to struct_size ...
This commit is contained in:
@@ -3721,8 +3721,10 @@ static int onenand_probe(struct mtd_info *mtd)
|
||||
this->dies = ONENAND_IS_DDP(this) ? 2 : 1;
|
||||
/* Maximum possible erase regions */
|
||||
mtd->numeraseregions = this->dies << 1;
|
||||
mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info)
|
||||
* (this->dies << 1), GFP_KERNEL);
|
||||
mtd->eraseregions =
|
||||
kcalloc(this->dies << 1,
|
||||
sizeof(struct mtd_erase_region_info),
|
||||
GFP_KERNEL);
|
||||
if (!mtd->eraseregions)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@@ -186,7 +186,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
|
||||
}
|
||||
|
||||
nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL);
|
||||
nbc->errloc = kmalloc(t*sizeof(*nbc->errloc), GFP_KERNEL);
|
||||
nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL);
|
||||
if (!nbc->eccmask || !nbc->errloc)
|
||||
goto fail;
|
||||
/*
|
||||
|
@@ -565,8 +565,9 @@ static int __init alloc_device(struct nandsim *ns)
|
||||
err = -EINVAL;
|
||||
goto err_close;
|
||||
}
|
||||
ns->pages_written = vzalloc(BITS_TO_LONGS(ns->geom.pgnum) *
|
||||
sizeof(unsigned long));
|
||||
ns->pages_written =
|
||||
vzalloc(array_size(sizeof(unsigned long),
|
||||
BITS_TO_LONGS(ns->geom.pgnum)));
|
||||
if (!ns->pages_written) {
|
||||
NS_ERR("alloc_device: unable to allocate pages written array\n");
|
||||
err = -ENOMEM;
|
||||
@@ -582,7 +583,7 @@ static int __init alloc_device(struct nandsim *ns)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem));
|
||||
ns->pages = vmalloc(array_size(sizeof(union ns_mem), ns->geom.pgnum));
|
||||
if (!ns->pages) {
|
||||
NS_ERR("alloc_device: unable to allocate page array\n");
|
||||
return -ENOMEM;
|
||||
|
@@ -2510,8 +2510,8 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
|
||||
if (!nandc->regs)
|
||||
return -ENOMEM;
|
||||
|
||||
nandc->reg_read_buf = devm_kzalloc(nandc->dev,
|
||||
MAX_REG_RD * sizeof(*nandc->reg_read_buf),
|
||||
nandc->reg_read_buf = devm_kcalloc(nandc->dev,
|
||||
MAX_REG_RD, sizeof(*nandc->reg_read_buf),
|
||||
GFP_KERNEL);
|
||||
if (!nandc->reg_read_buf)
|
||||
return -ENOMEM;
|
||||
|
@@ -1038,7 +1038,7 @@ static int s3c24xx_nand_probe_dt(struct platform_device *pdev)
|
||||
if (!pdata->nr_sets)
|
||||
return 0;
|
||||
|
||||
sets = devm_kzalloc(&pdev->dev, sizeof(*sets) * pdata->nr_sets,
|
||||
sets = devm_kcalloc(&pdev->dev, pdata->nr_sets, sizeof(*sets),
|
||||
GFP_KERNEL);
|
||||
if (!sets)
|
||||
return -ENOMEM;
|
||||
|
Reference in New Issue
Block a user