mtd: rawnand: sunxi: Use struct_size()
authorBoris Brezillon <boris.brezillon@bootlin.com>
Sat, 15 Dec 2018 08:24:32 +0000 (09:24 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 5 Feb 2019 14:39:38 +0000 (15:39 +0100)
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>
drivers/mtd/nand/raw/sunxi_nand.c

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