Re: [PATCH] USB: core: limit access to rawdescriptors which were not allocated

From: kernel test robot
Date: Tue Aug 25 2020 - 14:03:39 EST


Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on usb/usb-testing]
[also build test ERROR on balbi-usb/testing/next peter.chen-usb/ci-for-usb-next v5.9-rc2 next-20200825]
[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]

url: https://github.com/0day-ci/linux/commits/yanfei-xu-windriver-com/USB-core-limit-access-to-rawdescriptors-which-were-not-allocated/20200826-002050
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce (this is a W=1 build):
# save the attached .config to linux build tree
make W=1 ARCH=i386

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

drivers/usb/core/sysfs.c: In function 'read_descriptors':
>> drivers/usb/core/sysfs.c:899:12: error: 'USB_MAXCONFIG' undeclared (first use in this function); did you mean 'USB_DT_CONFIG'?
899 | cfgno < USB_MAXCONFIG; ++cfgno) {
| ^~~~~~~~~~~~~
| USB_DT_CONFIG
drivers/usb/core/sysfs.c:899:12: note: each undeclared identifier is reported only once for each function it appears in

# https://github.com/0day-ci/linux/commit/dda85cff0852edc4723d1175486a50024ee7289a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review yanfei-xu-windriver-com/USB-core-limit-access-to-rawdescriptors-which-were-not-allocated/20200826-002050
git checkout dda85cff0852edc4723d1175486a50024ee7289a
vim +899 drivers/usb/core/sysfs.c

880
881 static ssize_t
882 read_descriptors(struct file *filp, struct kobject *kobj,
883 struct bin_attribute *attr,
884 char *buf, loff_t off, size_t count)
885 {
886 struct device *dev = kobj_to_dev(kobj);
887 struct usb_device *udev = to_usb_device(dev);
888 size_t nleft = count;
889 size_t srclen, n;
890 int cfgno;
891 void *src;
892
893 /* The binary attribute begins with the device descriptor.
894 * Following that are the raw descriptor entries for all the
895 * configurations (config plus subsidiary descriptors).
896 */
897 for (cfgno = -1; cfgno < udev->descriptor.bNumConfigurations &&
898 nleft > 0 &&
> 899 cfgno < USB_MAXCONFIG; ++cfgno) {
900 if (cfgno < 0) {
901 src = &udev->descriptor;
902 srclen = sizeof(struct usb_device_descriptor);
903 } else {
904 src = udev->rawdescriptors[cfgno];
905 srclen = __le16_to_cpu(udev->config[cfgno].desc.
906 wTotalLength);
907 }
908 if (off < srclen) {
909 n = min(nleft, srclen - (size_t) off);
910 memcpy(buf, src + off, n);
911 nleft -= n;
912 buf += n;
913 off = 0;
914 } else {
915 off -= srclen;
916 }
917 }
918 return count - nleft;
919 }
920

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip