[U-Boot] [PATCH] drivers: usb: fsl: Fix NULL terminating issue for usb controller name string

Rajesh Bhagat rajesh.bhagat at nxp.com
Wed Jun 1 13:17:31 CEST 2016


Fixes NULL terminating issue for usb controller name string and
performs code cleanup for intializing variables current_usb_controller
and usb_phy.

Signed-off-by: Rajesh Bhagat <rajesh.bhagat at nxp.com>
---
 drivers/usb/host/ehci-fsl.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index a43d37d..a806993 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -49,11 +49,9 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	struct usb_ehci *ehci = NULL;
 	const char *phy_type = NULL;
 	size_t len;
-	char current_usb_controller[5];
+	char current_usb_controller[5] = {0};
 #ifdef CONFIG_SYS_FSL_USB_INTERNAL_UTMI_PHY
-	char usb_phy[5];
-
-	usb_phy[0] = '\0';
+	char usb_phy[5] = {0};
 #endif
 	if (has_erratum_a007075()) {
 		/*
@@ -64,8 +62,8 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 		 */
 		mdelay(5);
 	}
-	memset(current_usb_controller, '\0', 5);
-	snprintf(current_usb_controller, 4, "usb%d", index+1);
+	snprintf(current_usb_controller, sizeof(current_usb_controller),
+		 "usb%d", index+1);
 
 	switch (index) {
 	case 0:
-- 
1.7.7.4



More information about the U-Boot mailing list