Skip to content

Commit df84eb1

Browse files
authored
Merge pull request #10653 from desowin/stm-usb-host
STM USBHALHost: Fix NULL pointer dereference
2 parents a2c0294 + 5d33fe1 commit df84eb1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

features/unsupported/USBHost/targets/TARGET_STM/USBHALHost_STM.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@ static gpio_t gpio_powerpin;
122122

123123
void usb_vbus(uint8_t state)
124124
{
125-
if (state == 0) {
126-
gpio_write(&gpio_powerpin, USB_POWER_OFF);
125+
if (gpio_powerpin.reg_set && gpio_powerpin.reg_clr) {
126+
if (state == 0) {
127+
gpio_write(&gpio_powerpin, USB_POWER_OFF);
128+
} else {
129+
gpio_write(&gpio_powerpin, USB_POWER_ON);
130+
}
127131
} else {
128-
gpio_write(&gpio_powerpin, USB_POWER_ON);
132+
/* The board does not have GPIO pin to control usb supply */
129133
}
130134
wait(0.2);
131135
}

0 commit comments

Comments
 (0)