Skip to contentSkip to conversation

usb: fsl: Fix NULL terminating issue for usb controller name string

PATCH New Rajesh Bhagat 2 participants 2 messages Jun 18, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: fsl: Fix NULL terminating issue for usb controller name string

Fixes NULL terminating issue for usb controller name string by using sizeof operator.

---
 drivers/usb/host/ehci-fsl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/host/ehci-fsl.c +2 -1
index a43d37d..fa916ed 100644
@@ -65,7 +65,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:
Signature · 1 line
2.6.2.198.g614a2ac
Applied
#1 lore raw

PATCH v2 1/1 usb: fsl: Fix NULL terminating issue for usb controller name string

Quoted 4 lines · Rajesh Bhagat

Fixes NULL terminating issue for usb controller name string by using sizeof operator.

Applied, thanks.

Quoted 3 lines
---
 drivers/usb/host/ehci-fsl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Changelog for V2 is missing btw.

Quoted 15 lines
drivers/usb/host/ehci-fsl.c +2 -1
index a43d37d..fa916ed 100644
@@ -65,7 +65,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:
Signature · 2 lines
Best regards,
Marek Vasut