diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index a681d9b92bdab53a0aedafd832373da842a125fd..6ec38175a8170129a58f3954d7c438e488737a09 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -61,8 +61,6 @@
 #include "usb.h"
 #include "hcd.h"
 
-#define MAX_TOPO_LEVEL		6
-
 /* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */
 #define ALLOW_SERIAL_NUMBER
 
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 50b8bb2d1212b26f7e06a85a444b4125f307ab42..5b0b59b0d89b37709da23af08cf0271c193d9ebf 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -21,6 +21,8 @@
 
 #include <linux/rwsem.h>
 
+#define MAX_TOPO_LEVEL		6
+
 /* This file contains declarations of usbcore internals that are mostly
  * used or exposed by Host Controller Drivers.
  */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index e678ed8bd8c237be56181d01a8fc6935259e2bb9..3251120b414e135285110d3b890c266a06d8ff54 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1051,6 +1051,12 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	desc = intf->cur_altsetting;
 	hdev = interface_to_usbdev(intf);
 
+	if (hdev->level == MAX_TOPO_LEVEL) {
+		dev_err(&intf->dev, "Unsupported bus topology: "
+				"hub nested too deep\n");
+		return -E2BIG;
+	}
+
 #ifdef	CONFIG_USB_OTG_BLACKLIST_HUB
 	if (hdev->parent) {
 		dev_warn(&intf->dev, "ignoring external hub\n");