Skip to content

Commit 8e812e9

Browse files
Prashanth Kgregkh
authored andcommitted
usb: gadget: Check bmAttributes only if configuration is valid
If the USB configuration is not valid, then avoid checking for bmAttributes to prevent null pointer deference. Cc: stable <[email protected]> Fixes: 40e89ff ("usb: gadget: Set self-powered based on MaxPower and bmAttributes") Signed-off-by: Prashanth K <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 487cfd4 commit 8e812e9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/usb/gadget/composite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static int set_config(struct usb_composite_dev *cdev,
10511051
usb_gadget_set_remote_wakeup(gadget, 0);
10521052
done:
10531053
if (power > USB_SELF_POWER_VBUS_MAX_DRAW ||
1054-
!(c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
1054+
(c && !(c->bmAttributes & USB_CONFIG_ATT_SELFPOWER)))
10551055
usb_gadget_clear_selfpowered(gadget);
10561056
else
10571057
usb_gadget_set_selfpowered(gadget);

0 commit comments

Comments
 (0)