Commit 0a5b6824 authored by Johann Fischer's avatar Johann Fischer Committed by Carles Cufi
Browse files

drivers: udc_virtual: fix bus SUSPEND, RESUME, RESET event handling

Only UVB_EVT_REQUEST type passes the pkt argument.
This was overlooked in the last refactoring and
resulted in a zero pointer dereference.

Signed-off-by: default avatarJohann Fischer <johann.fischer@nordicsemi.no>
parent 76b91c70
Loading
Loading
Loading
Loading
+7 −0
Changes for drivers/usb/udc/udc_virtual.c: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -362,14 +362,21 @@ static void udc_vrt_uvb_cb(const void *const vrt_priv,

	switch (type) {
	case UVB_EVT_VBUS_REMOVED:
		__fallthrough;
	case UVB_EVT_VBUS_READY:
		if (udc_is_initialized(dev)) {
			vrt_submit_uvb_event(dev, type, NULL);
		}
		break;
	case UVB_EVT_SUSPEND:
		__fallthrough;
	case UVB_EVT_RESUME:
		__fallthrough;
	case UVB_EVT_RESET:
		if (udc_is_enabled(dev)) {
			vrt_submit_uvb_event(dev, type, NULL);
		}
		break;
	case UVB_EVT_REQUEST:
		if (udc_is_enabled(dev) && priv->addr == pkt->addr) {
			vrt_submit_uvb_event(dev, type, pkt);