]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: ls1021a: Remove the inappropriate use of the function 'sprintf'
authorAlison Wang <b18965@freescale.com>
Mon, 11 May 2015 07:39:47 +0000 (15:39 +0800)
committerYork Sun <yorksun@freescale.com>
Mon, 20 Jul 2015 18:44:38 +0000 (11:44 -0700)
As the function 'sprintf' does not check buffer boundaries but outputs
to the buffer 'enet' of fixed size (16), this patch removes the function
'sprintf', and uses 'strcpy' instead. It will assign the character
arrays 'enet' and 'phy' the corresponding character strings.

Signed-off-by: Alison Wang <alison.wang@freescale.com>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: York Sun <yorksun@freescale.com>
arch/arm/cpu/armv7/ls102xa/fdt.c

index 71a175392fd1c063e9149187694c0d7b8eb9f249..e01d91178054e7920219d3117ea95e1b8ce98976 100644 (file)
@@ -29,29 +29,30 @@ void ft_fixup_enet_phy_connect_type(void *fdt)
        char phy[16];
        int phy_node;
        int i = 0;
-       int enet_id = 0;
        uint32_t ph;
 
        while ((dev = eth_get_dev_by_index(i++)) != NULL) {
-               if (strstr(dev->name, "eTSEC1"))
-                       enet_id = 0;
-               else if (strstr(dev->name, "eTSEC2"))
-                       enet_id = 1;
-               else if (strstr(dev->name, "eTSEC3"))
-                       enet_id = 2;
-               else
+               if (strstr(dev->name, "eTSEC1")) {
+                       strcpy(enet, "ethernet0");
+                       strcpy(phy, "enet0_rgmii_phy");
+               } else if (strstr(dev->name, "eTSEC2")) {
+                       strcpy(enet, "ethernet1");
+                       strcpy(phy, "enet1_rgmii_phy");
+               } else if (strstr(dev->name, "eTSEC3")) {
+                       strcpy(enet, "ethernet2");
+                       strcpy(phy, "enet2_rgmii_phy");
+               } else {
                        continue;
+               }
 
                priv = dev->priv;
                if (priv->flags & TSEC_SGMII)
                        continue;
 
-               sprintf(enet, "ethernet%d", enet_id);
                enet_path = fdt_get_alias(fdt, enet);
                if (!enet_path)
                        continue;
 
-               sprintf(phy, "enet%d_rgmii_phy", enet_id);
                phy_path = fdt_get_alias(fdt, phy);
                if (!phy_path)
                        continue;