mtd: oxnas_nand: Allocating more than necessary in probe()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Wed May 10 19:59:15 PDT 2017


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=b98e1995e4fa9030474a61ed0dbc033464fe5ea0
Commit:     b98e1995e4fa9030474a61ed0dbc033464fe5ea0
Parent:     4ca41cb2ae09bfd9f84f053b8b9966e1bb8accc4
Author:     Dan Carpenter <dan.carpenter at oracle.com>
AuthorDate: Tue Apr 25 12:19:49 2017 +0300
Committer:  Brian Norris <computersforpeace at gmail.com>
CommitDate: Tue May 2 15:54:49 2017 -0700

    mtd: oxnas_nand: Allocating more than necessary in probe()
    
    We only need to allocate sizeof(struct oxnas_nand_ctrl) which is 192
    bytes and not sizeof(struct nand_chip) which is a much larger 3056
    bytes.
    
    Fixes: 668592492409 ("mtd: nand: Add OX820 NAND Support")
    Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
    Acked-by: Neil Armstrong <narmstrong at baylibre.com>
    Acked-by: Boris Brezillon <boris.brezillon at free-electrons.com>
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
 drivers/mtd/nand/oxnas_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/oxnas_nand.c b/drivers/mtd/nand/oxnas_nand.c
index 3e3bf3b..1b207aa 100644
--- a/drivers/mtd/nand/oxnas_nand.c
+++ b/drivers/mtd/nand/oxnas_nand.c
@@ -91,7 +91,7 @@ static int oxnas_nand_probe(struct platform_device *pdev)
 	int err = 0;
 
 	/* Allocate memory for the device structure (and zero it) */
-	oxnas = devm_kzalloc(&pdev->dev, sizeof(struct nand_chip),
+	oxnas = devm_kzalloc(&pdev->dev, sizeof(*oxnas),
 			     GFP_KERNEL);
 	if (!oxnas)
 		return -ENOMEM;



More information about the linux-mtd-cvs mailing list