]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ls1012a, pfe_eth: Update probe to avoid resource leak
authorChaitanya Sakinam <chaitanya.sakinam@nxp.com>
Thu, 10 Sep 2020 11:20:54 +0000 (16:50 +0530)
committerPriyanka Jain <priyanka.jain@nxp.com>
Thu, 24 Sep 2020 15:27:32 +0000 (20:57 +0530)
PFE DDR addresses are now stored on to a stack varaiable rather
dynamic allocation.

Signed-off-by: Chaitanya Sakinam <chaitanya.sakinam@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
drivers/net/pfe_eth/pfe_eth.c

index b74974c99a53469734cd9ecc6b1eeb802e466d21..3b4ca0393c0e310919d1c4d8e7d8276721790abc 100644 (file)
@@ -214,27 +214,22 @@ static int pfe_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 static int pfe_eth_probe(struct udevice *dev)
 {
        struct pfe_eth_dev *priv = dev_get_priv(dev);
-       struct pfe_ddr_address *pfe_addr;
+       struct pfe_ddr_address pfe_addr;
        struct pfe_eth_pdata *pdata = dev_get_platdata(dev);
        int ret = 0;
        static int init_done;
 
        if (!init_done) {
-               pfe_addr = (struct pfe_ddr_address *)malloc(sizeof
-                                                   (struct pfe_ddr_address));
-               if (!pfe_addr)
-                       return -ENOMEM;
-
-               pfe_addr->ddr_pfe_baseaddr =
+               pfe_addr.ddr_pfe_baseaddr =
                                (void *)pdata->pfe_ddr_addr.ddr_pfe_baseaddr;
-               pfe_addr->ddr_pfe_phys_baseaddr =
+               pfe_addr.ddr_pfe_phys_baseaddr =
                (unsigned long)pdata->pfe_ddr_addr.ddr_pfe_phys_baseaddr;
 
                debug("ddr_pfe_baseaddr: %p, ddr_pfe_phys_baseaddr: %08x\n",
-                     pfe_addr->ddr_pfe_baseaddr,
-                     (u32)pfe_addr->ddr_pfe_phys_baseaddr);
+                     pfe_addr.ddr_pfe_baseaddr,
+                     (u32)pfe_addr.ddr_pfe_phys_baseaddr);
 
-               ret = pfe_drv_init(pfe_addr);
+               ret = pfe_drv_init(&pfe_addr);
                if (ret)
                        return ret;