mtd: rawnand: sunxi: Use struct_size()

Use struct_size() to calculate sunxi_nand object size.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
Boris Brezillon 2018-12-15 09:24:32 +01:00 committed by Miquel Raynal
parent f385ebf074
commit 6c721acdd5
1 changed files with 1 additions and 3 deletions

View File

@ -1871,9 +1871,7 @@ static int sunxi_nand_chip_init(struct device *dev, struct sunxi_nfc *nfc,
return -EINVAL; return -EINVAL;
} }
sunxi_nand = devm_kzalloc(dev, sunxi_nand = devm_kzalloc(dev, struct_size(sunxi_nand, sels, nsels),
sizeof(*sunxi_nand) +
(nsels * sizeof(struct sunxi_nand_chip_sel)),
GFP_KERNEL); GFP_KERNEL);
if (!sunxi_nand) { if (!sunxi_nand) {
dev_err(dev, "could not allocate chip\n"); dev_err(dev, "could not allocate chip\n");