From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gY5Fk-0006rS-GP for linux-mtd@lists.infradead.org; Sat, 15 Dec 2018 08:24:53 +0000 From: Boris Brezillon To: Boris Brezillon , Richard Weinberger , Miquel Raynal , linux-mtd@lists.infradead.org Cc: David Woodhouse , Brian Norris , Marek Vasut Subject: [PATCH v2 2/7] mtd: rawnand: sunxi: Use struct_size() Date: Sat, 15 Dec 2018 09:24:32 +0100 Message-Id: <20181215082437.9175-3-boris.brezillon@bootlin.com> In-Reply-To: <20181215082437.9175-1-boris.brezillon@bootlin.com> References: <20181215082437.9175-1-boris.brezillon@bootlin.com> List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Use struct_size() to calculate sunxi_nand object size. Signed-off-by: Boris Brezillon --- drivers/mtd/nand/raw/sunxi_nand.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 9139fc003b1a..1453392a53e7 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -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"); -- 2.17.1