USB: dummy-hcd: Fix uninitialized array use in init()
authorBui Quang Minh <minhquangbui99@gmail.com>
Fri, 4 Dec 2020 06:24:49 +0000 (06:24 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Dec 2020 12:46:45 +0000 (13:46 +0100)
commit e90cfa813da7a527785033a0b247594c2de93dd8 upstream.

This error path

err_add_pdata:
for (i = 0; i < mod_data.num; i++)
kfree(dum[i]);

can be triggered when not all dum's elements are initialized.

Fix this by initializing all dum's elements to NULL.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Link: https://lore.kernel.org/r/1607063090-3426-1-git-send-email-minhquangbui99@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/udc/dummy_hcd.c

index a0c1d77a7e38d19160638ab2da1dcefb3043621e..df27b174b4d06585425b1b68375ae3fe0558e9ba 100644 (file)
@@ -2742,7 +2742,7 @@ static int __init init(void)
 {
        int     retval = -ENOMEM;
        int     i;
-       struct  dummy *dum[MAX_NUM_UDC];
+       struct  dummy *dum[MAX_NUM_UDC] = {};
 
        if (usb_disabled())
                return -ENODEV;