mtd: oxnas_nand: Allocating more than necessary in probe()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 25 Apr 2017 09:19:49 +0000 (12:19 +0300)
committerBrian Norris <computersforpeace@gmail.com>
Tue, 2 May 2017 22:54:49 +0000 (15:54 -0700)
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@oracle.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
drivers/mtd/nand/oxnas_nand.c

index 3e3bf3b364d2b63c1dcf1869e45b5bd5c9f63616..1b207aac840c4b169c4e2168f1104309c729ad0c 100644 (file)
@@ -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;