From patchwork Sat Dec 15 08:12:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 1013851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bgm+rQRp"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43H0XZ2G3wz9s3C for ; Sat, 15 Dec 2018 19:13:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=jHzbyHQ/AZYORTUEVwvhOlsr8sM7knXEq53C+dGtKhI=; b=bgm+rQRpl6bcUMpa6lCUz7WWTH EoZk4kAh+iet1EX4xBUthmd2Fmfh3Qxz2OSyqQXKZ1+iqj71QRu56fRHTTs76x7FgPmwnBhKzbMtd F708RMnPwWp2Uw7fUvduYb4Xyf0NyPifqpZ1KhwYXcL+pYyTFyhMygFFLKee42i3giDadnXvw6/Sv pYO6xgFMCoNL0zlNRQ5Sv/F9M0fBjv3hdGESKCO5DBUqXFIwk12nHmfwnwVNaPj8+i3tKaNRJcrUQ eXAMPoU1pzPJz663YDwunIyWutWZtmCAz9orkREtfJ/QU/iaTJKw5u/JIyv6P9ycBqAE/Qi4cyuHu p49HOoSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gY54B-0002FE-Cq; Sat, 15 Dec 2018 08:12:55 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gY53m-0001pl-S4 for linux-mtd@lists.infradead.org; Sat, 15 Dec 2018 08:12:34 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 6BE4920BE6; Sat, 15 Dec 2018 09:12:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (unknown [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 3BB5D207AD; Sat, 15 Dec 2018 09:12:16 +0100 (CET) From: Boris Brezillon To: Boris Brezillon , Richard Weinberger , Miquel Raynal , linux-mtd@lists.infradead.org Subject: [PATCH 2/5] mtd: rawnand: sunxi: Use struct_size() Date: Sat, 15 Dec 2018 09:12:11 +0100 Message-Id: <20181215081214.4935-2-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181215081214.4935-1-boris.brezillon@bootlin.com> References: <20181215081214.4935-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181215_001231_035256_E8F852C4 X-CRM114-Status: GOOD ( 10.81 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org 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");