1 From cf4df407e0d7cde60a45369c2a3414d18e2d4fdd Mon Sep 17 00:00:00 2001
2 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3 Date: Wed, 13 Dec 2017 11:59:39 +0100
4 Subject: Revert "USB: core: only clean up what we allocated"
6 From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
8 commit cf4df407e0d7cde60a45369c2a3414d18e2d4fdd upstream.
10 This reverts commit 32fd87b3bbf5f7a045546401dfe2894dbbf4d8c3.
12 Alan wrote a better fix for this...
14 Cc: Andrey Konovalov <andreyknvl@google.com>
15 Cc: stable <stable@vger.kernel.org>
16 Cc: Nathan Chancellor <natechancellor@gmail.com>
17 Cc: Arnd Bergmann <arnd@arndb.de>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21 drivers/usb/core/config.c | 9 +++------
22 1 file changed, 3 insertions(+), 6 deletions(-)
24 --- a/drivers/usb/core/config.c
25 +++ b/drivers/usb/core/config.c
26 @@ -768,21 +768,18 @@ void usb_destroy_configuration(struct us
29 if (dev->rawdescriptors) {
30 - for (i = 0; i < dev->descriptor.bNumConfigurations &&
31 - i < USB_MAXCONFIG; i++)
32 + for (i = 0; i < dev->descriptor.bNumConfigurations; i++)
33 kfree(dev->rawdescriptors[i]);
35 kfree(dev->rawdescriptors);
36 dev->rawdescriptors = NULL;
39 - for (c = 0; c < dev->descriptor.bNumConfigurations &&
40 - c < USB_MAXCONFIG; c++) {
41 + for (c = 0; c < dev->descriptor.bNumConfigurations; c++) {
42 struct usb_host_config *cf = &dev->config[c];
45 - for (i = 0; i < cf->desc.bNumInterfaces &&
46 - i < USB_MAXINTERFACES; i++) {
47 + for (i = 0; i < cf->desc.bNumInterfaces; i++) {
48 if (cf->intf_cache[i])
49 kref_put(&cf->intf_cache[i]->ref,
50 usb_release_interface_cache);