cherry-embedded / CherryUSB

CherryUSB is a tiny and portable USB Stack (device & host) for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.14k stars 245 forks source link

lsusb的-t命令会出现空指针异常 #163

Closed flyranchao closed 5 months ago

flyranchao commented 5 months ago
        for (uint8_t port = 0; port < hub->hub_desc.bNbrPorts; port++) {
            hport = &hub->child[port];
            if (hport->connected) {
                for (uint8_t i = 0; i < hport->config.config_desc.bNumInterfaces; i++) {
                    if(hport->config.intf[i].class_driver != NULL) { //建议这里加上判空处理。
                        if (hport->config.intf[i].class_driver->driver_name) {
                            USB_LOG_RAW("    |__Port %u,Port addr:0x%02x,If %u,ClassDriver=%s\r\n",
                                hport->port,
                                hport->dev_addr,
                                i,
                                hport->config.intf[i].class_driver->driver_name);
                        }
                    }
                }
            }
        }
    }
sakumisu commented 5 months ago

不需要增加,如果没有class driver,必须不准使用