usb: gadget: composite: add null pointer check

The cdev->config means the currently active configuration and
it might be null, fix it by adding null pointer check.

Change-Id: I18261653436186c342b447c24ef46a8acc42825f
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
Frank Wang 2019-06-28 11:12:39 +08:00 committed by Jianhong Chen
parent 87f9541a89
commit 1bca07a1ff
1 changed files with 4 additions and 0 deletions

View File

@ -958,10 +958,14 @@ unknown:
*/
switch (ctrl->bRequestType & USB_RECIP_MASK) {
case USB_RECIP_INTERFACE:
if (!cdev->config)
break;
f = cdev->config->interface[intf];
break;
case USB_RECIP_ENDPOINT:
if (!cdev->config)
break;
endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f);
list_for_each_entry(f, &cdev->config->functions, list) {
if (test_bit(endp, f->endpoints))