Hi Pavitra, kernel test robot noticed the following build errors: [auto build test ERROR on usb/usb-testing] [also build test ERROR on usb/usb-next usb/usb-linus westeri-thunderbolt/next linus/master v7.0 next-20260417] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Pavitra-Jha/usb-gadget-udc-max3420-validate-endpoint-index-before-array-access/20260418-074148 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing patch link: https://lore.kernel.org/r/20260411180012.830193-1-jhapavitra98%40gmail.com patch subject: [PATCH] usb: gadget: udc: max3420: validate endpoint index before array access config: loongarch-allmodconfig compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Closes: https://lore.kernel.org/oe-kbuild-all/202604191819.2IEGJjoB-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/usb/gadget/udc/max3420_udc.c:551:3: error: use of undeclared identifier 'id' 551 | id = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK; | ^ drivers/usb/gadget/udc/max3420_udc.c:552:7: error: use of undeclared identifier 'id' 552 | if (id >= MAX3420_MAX_EPS) | ^ drivers/usb/gadget/udc/max3420_udc.c:554:17: error: use of undeclared identifier 'id' 554 | ep = &udc->ep[id]; | ^ >> drivers/usb/gadget/udc/max3420_udc.c:603:9: error: use of undeclared label 'stall' 603 | goto stall; | ^ 4 errors generated. vim +/id +551 drivers/usb/gadget/udc/max3420_udc.c 534 535 static void max3420_getstatus(struct max3420_udc *udc) 536 { 537 struct max3420_ep *ep; 538 u16 status = 0; 539 540 switch (udc->setup.bRequestType & USB_RECIP_MASK) { 541 case USB_RECIP_DEVICE: 542 /* Get device status */ 543 status = udc->gadget.is_selfpowered << USB_DEVICE_SELF_POWERED; 544 status |= (udc->remote_wkp << USB_DEVICE_REMOTE_WAKEUP); 545 break; 546 case USB_RECIP_INTERFACE: 547 if (udc->driver->setup(&udc->gadget, &udc->setup) < 0) 548 goto stall; 549 break; 550 case USB_RECIP_ENDPOINT: > 551 id = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK; 552 if (id >= MAX3420_MAX_EPS) 553 goto stall; 554 ep = &udc->ep[id]; 555 if (udc->setup.wIndex & USB_DIR_IN) { 556 if (!ep->ep_usb.caps.dir_in) 557 goto stall; 558 } else { 559 if (!ep->ep_usb.caps.dir_out) 560 goto stall; 561 } 562 if (ep->halted) 563 status = 1 << USB_ENDPOINT_HALT; 564 break; 565 default: 566 goto stall; 567 } 568 569 status = cpu_to_le16(status); 570 spi_wr_buf(udc, MAX3420_REG_EP0FIFO, &status, 2); 571 spi_wr8_ack(udc, MAX3420_REG_EP0BC, 2, 1); 572 return; 573 stall: 574 dev_err(udc->dev, "Can't respond to getstatus request\n"); 575 spi_wr8(udc, MAX3420_REG_EPSTALLS, STLEP0IN | STLEP0OUT | STLSTAT); 576 } 577 578 static void max3420_set_clear_feature(struct max3420_udc *udc) 579 { 580 struct max3420_ep *ep; 581 int set = udc->setup.bRequest == USB_REQ_SET_FEATURE; 582 unsigned long flags; 583 int id; 584 585 switch (udc->setup.bRequestType) { 586 case USB_RECIP_DEVICE: 587 if (udc->setup.wValue != USB_DEVICE_REMOTE_WAKEUP) 588 break; 589 590 if (udc->setup.bRequest == USB_REQ_SET_FEATURE) 591 udc->remote_wkp = 1; 592 else 593 udc->remote_wkp = 0; 594 595 return spi_ack_ctrl(udc); 596 597 case USB_RECIP_ENDPOINT: 598 if (udc->setup.wValue != USB_ENDPOINT_HALT) 599 break; 600 601 id = udc->setup.wIndex & USB_ENDPOINT_NUMBER_MASK; 602 if (id >= MAX3420_MAX_EPS) > 603 goto stall; 604 ep = &udc->ep[id]; 605 606 spin_lock_irqsave(&ep->lock, flags); 607 ep->todo &= ~STALL_EP; 608 if (set) 609 ep->todo |= STALL; 610 else 611 ep->todo |= UNSTALL; 612 spin_unlock_irqrestore(&ep->lock, flags); 613 614 spi_max3420_stall(ep); 615 return; 616 default: 617 break; 618 } 619 620 dev_err(udc->dev, "Can't respond to SET/CLEAR FEATURE\n"); 621 spi_wr8(udc, MAX3420_REG_EPSTALLS, STLEP0IN | STLEP0OUT | STLSTAT); 622 } 623 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki