public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] arm: ls1021a: Remove the inappropriate use of the function 'sprintf'
@ 2015-05-11  7:39 Alison Wang
  2015-05-11 19:16 ` Joe Hershberger
  2015-07-20 21:12 ` York Sun
  0 siblings, 2 replies; 3+ messages in thread
From: Alison Wang @ 2015-05-11  7:39 UTC (permalink / raw)
  To: u-boot

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>
---
 arch/arm/cpu/armv7/ls102xa/fdt.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/arch/arm/cpu/armv7/ls102xa/fdt.c b/arch/arm/cpu/armv7/ls102xa/fdt.c
index 71a1753..e01d911 100644
--- a/arch/arm/cpu/armv7/ls102xa/fdt.c
+++ b/arch/arm/cpu/armv7/ls102xa/fdt.c
@@ -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;
-- 
2.1.0.27.g96db324

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] arm: ls1021a: Remove the inappropriate use of the function 'sprintf'
  2015-05-11  7:39 [U-Boot] [PATCH] arm: ls1021a: Remove the inappropriate use of the function 'sprintf' Alison Wang
@ 2015-05-11 19:16 ` Joe Hershberger
  2015-07-20 21:12 ` York Sun
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Hershberger @ 2015-05-11 19:16 UTC (permalink / raw)
  To: u-boot

On Mon, May 11, 2015 at 2:39 AM, Alison Wang <b18965@freescale.com> wrote:
> 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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] arm: ls1021a: Remove the inappropriate use of the function 'sprintf'
  2015-05-11  7:39 [U-Boot] [PATCH] arm: ls1021a: Remove the inappropriate use of the function 'sprintf' Alison Wang
  2015-05-11 19:16 ` Joe Hershberger
@ 2015-07-20 21:12 ` York Sun
  1 sibling, 0 replies; 3+ messages in thread
From: York Sun @ 2015-07-20 21:12 UTC (permalink / raw)
  To: u-boot



On 05/11/2015 12:39 AM, Alison Wang wrote:
> 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>
> ---

Applied to u-boot-fsl-qoriq master branch.

York

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-20 21:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-11  7:39 [U-Boot] [PATCH] arm: ls1021a: Remove the inappropriate use of the function 'sprintf' Alison Wang
2015-05-11 19:16 ` Joe Hershberger
2015-07-20 21:12 ` York Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox