Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'usb-5.9-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB/PHY fixes from Greg KH:
"Here are some small USB and PHY driver fixes for 5.9-rc8

The PHY driver fix resolves an issue found by Dan Carpenter for a
memory leak.

The USB fixes fall into two groups:

- usb gadget fix from Bryan that is a fix for a previous security fix
that showed up in in-the-wild testing

- usb core driver matching bugfixes. This fixes a bug that has
plagued the both the usbip driver and syzbot testing tools this -rc
release cycle. All is now working properly so usbip connections
will work, and syzbot can get back to fuzzing USB drivers properly.

All have been in linux-next for a while with no reported issues"

* tag 'usb-5.9-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
usbcore/driver: Accommodate usbip
usbcore/driver: Fix incorrect downcast
usbcore/driver: Fix specific driver selection
Revert "usbip: Implement a match function to fix usbip"
USB: gadget: f_ncm: Fix NDP16 datagram validation
phy: ti: am654: Fix a leak in serdes_am654_probe()

+40 -52
+4 -2
drivers/phy/ti/phy-am654-serdes.c
··· 725 725 pm_runtime_enable(dev); 726 726 727 727 phy = devm_phy_create(dev, NULL, &ops); 728 - if (IS_ERR(phy)) 729 - return PTR_ERR(phy); 728 + if (IS_ERR(phy)) { 729 + ret = PTR_ERR(phy); 730 + goto clk_err; 731 + } 730 732 731 733 phy_set_drvdata(phy, am654_phy); 732 734 phy_provider = devm_of_phy_provider_register(dev, serdes_am654_xlate);
+34 -16
drivers/usb/core/driver.c
··· 269 269 if (error) 270 270 return error; 271 271 272 + /* Probe the USB device with the driver in hand, but only 273 + * defer to a generic driver in case the current USB 274 + * device driver has an id_table or a match function; i.e., 275 + * when the device driver was explicitly matched against 276 + * a device. 277 + * 278 + * If the device driver does not have either of these, 279 + * then we assume that it can bind to any device and is 280 + * not truly a more specialized/non-generic driver, so a 281 + * return value of -ENODEV should not force the device 282 + * to be handled by the generic USB driver, as there 283 + * can still be another, more specialized, device driver. 284 + * 285 + * This accommodates the usbip driver. 286 + * 287 + * TODO: What if, in the future, there are multiple 288 + * specialized USB device drivers for a particular device? 289 + * In such cases, there is a need to try all matching 290 + * specialised device drivers prior to setting the 291 + * use_generic_driver bit. 292 + */ 272 293 error = udriver->probe(udev); 273 - if (error == -ENODEV && udriver != &usb_generic_driver) { 294 + if (error == -ENODEV && udriver != &usb_generic_driver && 295 + (udriver->id_table || udriver->match)) { 274 296 udev->use_generic_driver = 1; 275 297 return -EPROBE_DEFER; 276 298 } ··· 853 831 udev = to_usb_device(dev); 854 832 udrv = to_usb_device_driver(drv); 855 833 856 - if (udrv->id_table && 857 - usb_device_match_id(udev, udrv->id_table) != NULL) { 858 - return 1; 859 - } 834 + if (udrv->id_table) 835 + return usb_device_match_id(udev, udrv->id_table) != NULL; 860 836 861 837 if (udrv->match) 862 838 return udrv->match(udev); 863 - return 0; 839 + 840 + /* If the device driver under consideration does not have a 841 + * id_table or a match function, then let the driver's probe 842 + * function decide. 843 + */ 844 + return 1; 864 845 865 846 } else if (is_usb_interface(dev)) { 866 847 struct usb_interface *intf; ··· 930 905 return 0; 931 906 } 932 907 933 - static bool is_dev_usb_generic_driver(struct device *dev) 934 - { 935 - struct usb_device_driver *udd = dev->driver ? 936 - to_usb_device_driver(dev->driver) : NULL; 937 - 938 - return udd == &usb_generic_driver; 939 - } 940 - 941 908 static int __usb_bus_reprobe_drivers(struct device *dev, void *data) 942 909 { 943 910 struct usb_device_driver *new_udriver = data; 944 911 struct usb_device *udev; 945 912 int ret; 946 913 947 - if (!is_dev_usb_generic_driver(dev)) 914 + /* Don't reprobe if current driver isn't usb_generic_driver */ 915 + if (dev->driver != &usb_generic_driver.drvwrap.driver) 948 916 return 0; 949 917 950 918 udev = to_usb_device(dev); 951 919 if (usb_device_match_id(udev, new_udriver->id_table) == NULL && 952 - (!new_udriver->match || new_udriver->match(udev) != 0)) 920 + (!new_udriver->match || new_udriver->match(udev) == 0)) 953 921 return 0; 954 922 955 923 ret = device_reprobe(dev);
+2 -28
drivers/usb/gadget/function/f_ncm.c
··· 1189 1189 const struct ndp_parser_opts *opts = ncm->parser_opts; 1190 1190 unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0; 1191 1191 int dgram_counter; 1192 - bool ndp_after_header; 1193 1192 1194 1193 /* dwSignature */ 1195 1194 if (get_unaligned_le32(tmp) != opts->nth_sign) { ··· 1215 1216 } 1216 1217 1217 1218 ndp_index = get_ncm(&tmp, opts->ndp_index); 1218 - ndp_after_header = false; 1219 1219 1220 1220 /* Run through all the NDP's in the NTB */ 1221 1221 do { ··· 1230 1232 ndp_index); 1231 1233 goto err; 1232 1234 } 1233 - if (ndp_index == opts->nth_size) 1234 - ndp_after_header = true; 1235 1235 1236 1236 /* 1237 1237 * walk through NDP ··· 1308 1312 index2 = get_ncm(&tmp, opts->dgram_item_len); 1309 1313 dg_len2 = get_ncm(&tmp, opts->dgram_item_len); 1310 1314 1311 - if (index2 == 0 || dg_len2 == 0) 1312 - break; 1313 - 1314 1315 /* wDatagramIndex[1] */ 1315 - if (ndp_after_header) { 1316 - if (index2 < opts->nth_size + opts->ndp_size) { 1317 - INFO(port->func.config->cdev, 1318 - "Bad index: %#X\n", index2); 1319 - goto err; 1320 - } 1321 - } else { 1322 - if (index2 < opts->nth_size + opts->dpe_size) { 1323 - INFO(port->func.config->cdev, 1324 - "Bad index: %#X\n", index2); 1325 - goto err; 1326 - } 1327 - } 1328 1316 if (index2 > block_len - opts->dpe_size) { 1329 1317 INFO(port->func.config->cdev, 1330 1318 "Bad index: %#X\n", index2); 1331 - goto err; 1332 - } 1333 - 1334 - /* wDatagramLength[1] */ 1335 - if ((dg_len2 < 14 + crc_len) || 1336 - (dg_len2 > frame_max)) { 1337 - INFO(port->func.config->cdev, 1338 - "Bad dgram length: %#X\n", dg_len); 1339 1319 goto err; 1340 1320 } 1341 1321 ··· 1331 1359 ndp_len -= 2 * (opts->dgram_item_len * 2); 1332 1360 1333 1361 dgram_counter++; 1362 + if (index2 == 0 || dg_len2 == 0) 1363 + break; 1334 1364 } while (ndp_len > 2 * (opts->dgram_item_len * 2)); 1335 1365 } while (ndp_index); 1336 1366
-6
drivers/usb/usbip/stub_dev.c
··· 461 461 return; 462 462 } 463 463 464 - static bool usbip_match(struct usb_device *udev) 465 - { 466 - return true; 467 - } 468 - 469 464 #ifdef CONFIG_PM 470 465 471 466 /* These functions need usb_port_suspend and usb_port_resume, ··· 486 491 .name = "usbip-host", 487 492 .probe = stub_probe, 488 493 .disconnect = stub_disconnect, 489 - .match = usbip_match, 490 494 #ifdef CONFIG_PM 491 495 .suspend = stub_suspend, 492 496 .resume = stub_resume,