From 560747c22e8594e9ff255e8c6cf70d00fded69da Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Wed, 29 Jun 2022 15:29:34 +0200 Subject: [PATCH] lx_emul: active config validation in usb driver Fix genodelabs/genode#4567 --- repos/dde_linux/src/lib/lx_emul/usb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/repos/dde_linux/src/lib/lx_emul/usb.c b/repos/dde_linux/src/lib/lx_emul/usb.c index b3d8053849..ed328119cd 100644 --- a/repos/dde_linux/src/lib/lx_emul/usb.c +++ b/repos/dde_linux/src/lib/lx_emul/usb.c @@ -233,7 +233,7 @@ static int usb_rpc_call(void * data) if (usb_rpc_args.call == RELEASE_ALL) { i = 0; - num = udev->actconfig->desc.bNumInterfaces; + num = (udev->actconfig) ? udev->actconfig->desc.bNumInterfaces : 0; } else { i = usb_rpc_args.iface_num; num = i + 1; @@ -771,7 +771,7 @@ static int raw_notify(struct notifier_block *nb, unsigned long action, void *dat * policies. */ unsigned long class; - unsigned i; + unsigned i, num; struct usb_iface_urbs *urbs = (struct usb_iface_urbs*) kmalloc(sizeof(struct usb_iface_urbs), GFP_KERNEL); init_usb_anchor(&urbs->submitted); @@ -779,8 +779,12 @@ static int raw_notify(struct notifier_block *nb, unsigned long action, void *dat dev_set_drvdata(&udev->dev, urbs); - for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { - struct usb_interface * iface = udev->actconfig->interface[i]; + class = 0; + num = (udev->actconfig) ? + udev->actconfig->desc.bNumInterfaces : 0; + for (i = 0; i < num; i++) { + struct usb_interface * iface = + (udev->actconfig) ? udev->actconfig->interface[i] : NULL; if (!iface || !iface->cur_altsetting) continue; if (i == 0 || iface->cur_altsetting->desc.bInterfaceClass ==