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-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
"Here are some USB and PHY fixes for 4.4-rc6. All of them resolve some
reported problems. Full details in the shortlog"

* tag 'usb-4.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
USB: fix invalid memory access in hub_activate()
USB: ipaq.c: fix a timeout loop
phy: core: Get a refcount to phy in devm_of_phy_get_by_index()
phy: cygnus: pcie: add missing of_node_put
phy: miphy365x: add missing of_node_put
phy: miphy28lp: add missing of_node_put
phy: rockchip-usb: add missing of_node_put
phy: berlin-sata: add missing of_node_put
phy: mt65xx-usb3: add missing of_node_put
phy: brcmstb-sata: add missing of_node_put
phy: sun9i-usb: add USB dependency

+122 -47
+1
drivers/phy/Kconfig
··· 233 233 tristate "Allwinner sun9i SoC USB PHY driver" 234 234 depends on ARCH_SUNXI && HAS_IOMEM && OF 235 235 depends on RESET_CONTROLLER 236 + depends on USB_COMMON 236 237 select GENERIC_PHY 237 238 help 238 239 Enable this to support the transceiver that is part of Allwinner
+12 -4
drivers/phy/phy-bcm-cygnus-pcie.c
··· 128 128 struct phy_provider *provider; 129 129 struct resource *res; 130 130 unsigned cnt = 0; 131 + int ret; 131 132 132 133 if (of_get_child_count(node) == 0) { 133 134 dev_err(dev, "PHY no child node\n"); ··· 155 154 if (of_property_read_u32(child, "reg", &id)) { 156 155 dev_err(dev, "missing reg property for %s\n", 157 156 child->name); 158 - return -EINVAL; 157 + ret = -EINVAL; 158 + goto put_child; 159 159 } 160 160 161 161 if (id >= MAX_NUM_PHYS) { 162 162 dev_err(dev, "invalid PHY id: %u\n", id); 163 - return -EINVAL; 163 + ret = -EINVAL; 164 + goto put_child; 164 165 } 165 166 166 167 if (core->phys[id].phy) { 167 168 dev_err(dev, "duplicated PHY id: %u\n", id); 168 - return -EINVAL; 169 + ret = -EINVAL; 170 + goto put_child; 169 171 } 170 172 171 173 p = &core->phys[id]; 172 174 p->phy = devm_phy_create(dev, child, &cygnus_pcie_phy_ops); 173 175 if (IS_ERR(p->phy)) { 174 176 dev_err(dev, "failed to create PHY\n"); 175 - return PTR_ERR(p->phy); 177 + ret = PTR_ERR(p->phy); 178 + goto put_child; 176 179 } 177 180 178 181 p->core = core; ··· 196 191 dev_dbg(dev, "registered %u PCIe PHY(s)\n", cnt); 197 192 198 193 return 0; 194 + put_child: 195 + of_node_put(child); 196 + return ret; 199 197 } 200 198 201 199 static const struct of_device_id cygnus_pcie_phy_match_table[] = {
+14 -6
drivers/phy/phy-berlin-sata.c
··· 195 195 struct phy_provider *phy_provider; 196 196 struct phy_berlin_priv *priv; 197 197 struct resource *res; 198 - int i = 0; 198 + int ret, i = 0; 199 199 u32 phy_id; 200 200 201 201 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); ··· 237 237 if (of_property_read_u32(child, "reg", &phy_id)) { 238 238 dev_err(dev, "missing reg property in node %s\n", 239 239 child->name); 240 - return -EINVAL; 240 + ret = -EINVAL; 241 + goto put_child; 241 242 } 242 243 243 244 if (phy_id >= ARRAY_SIZE(phy_berlin_power_down_bits)) { 244 245 dev_err(dev, "invalid reg in node %s\n", child->name); 245 - return -EINVAL; 246 + ret = -EINVAL; 247 + goto put_child; 246 248 } 247 249 248 250 phy_desc = devm_kzalloc(dev, sizeof(*phy_desc), GFP_KERNEL); 249 - if (!phy_desc) 250 - return -ENOMEM; 251 + if (!phy_desc) { 252 + ret = -ENOMEM; 253 + goto put_child; 254 + } 251 255 252 256 phy = devm_phy_create(dev, NULL, &phy_berlin_sata_ops); 253 257 if (IS_ERR(phy)) { 254 258 dev_err(dev, "failed to create PHY %d\n", phy_id); 255 - return PTR_ERR(phy); 259 + ret = PTR_ERR(phy); 260 + goto put_child; 256 261 } 257 262 258 263 phy_desc->phy = phy; ··· 274 269 phy_provider = 275 270 devm_of_phy_provider_register(dev, phy_berlin_sata_phy_xlate); 276 271 return PTR_ERR_OR_ZERO(phy_provider); 272 + put_child: 273 + of_node_put(child); 274 + return ret; 277 275 } 278 276 279 277 static const struct of_device_id phy_berlin_sata_of_match[] = {
+12 -5
drivers/phy/phy-brcmstb-sata.c
··· 140 140 struct brcm_sata_phy *priv; 141 141 struct resource *res; 142 142 struct phy_provider *provider; 143 - int count = 0; 143 + int ret, count = 0; 144 144 145 145 if (of_get_child_count(dn) == 0) 146 146 return -ENODEV; ··· 163 163 if (of_property_read_u32(child, "reg", &id)) { 164 164 dev_err(dev, "missing reg property in node %s\n", 165 165 child->name); 166 - return -EINVAL; 166 + ret = -EINVAL; 167 + goto put_child; 167 168 } 168 169 169 170 if (id >= MAX_PORTS) { 170 171 dev_err(dev, "invalid reg: %u\n", id); 171 - return -EINVAL; 172 + ret = -EINVAL; 173 + goto put_child; 172 174 } 173 175 if (priv->phys[id].phy) { 174 176 dev_err(dev, "already registered port %u\n", id); 175 - return -EINVAL; 177 + ret = -EINVAL; 178 + goto put_child; 176 179 } 177 180 178 181 port = &priv->phys[id]; ··· 185 182 port->ssc_en = of_property_read_bool(child, "brcm,enable-ssc"); 186 183 if (IS_ERR(port->phy)) { 187 184 dev_err(dev, "failed to create PHY\n"); 188 - return PTR_ERR(port->phy); 185 + ret = PTR_ERR(port->phy); 186 + goto put_child; 189 187 } 190 188 191 189 phy_set_drvdata(port->phy, port); ··· 202 198 dev_info(dev, "registered %d port(s)\n", count); 203 199 204 200 return 0; 201 + put_child: 202 + of_node_put(child); 203 + return ret; 205 204 } 206 205 207 206 static struct platform_driver brcm_sata_phy_driver = {
+15 -6
drivers/phy/phy-core.c
··· 636 636 * @np: node containing the phy 637 637 * @index: index of the phy 638 638 * 639 - * Gets the phy using _of_phy_get(), and associates a device with it using 640 - * devres. On driver detach, release function is invoked on the devres data, 639 + * Gets the phy using _of_phy_get(), then gets a refcount to it, 640 + * and associates a device with it using devres. On driver detach, 641 + * release function is invoked on the devres data, 641 642 * then, devres data is freed. 642 643 * 643 644 */ ··· 652 651 return ERR_PTR(-ENOMEM); 653 652 654 653 phy = _of_phy_get(np, index); 655 - if (!IS_ERR(phy)) { 656 - *ptr = phy; 657 - devres_add(dev, ptr); 658 - } else { 654 + if (IS_ERR(phy)) { 659 655 devres_free(ptr); 656 + return phy; 660 657 } 658 + 659 + if (!try_module_get(phy->ops->owner)) { 660 + devres_free(ptr); 661 + return ERR_PTR(-EPROBE_DEFER); 662 + } 663 + 664 + get_device(&phy->dev); 665 + 666 + *ptr = phy; 667 + devres_add(dev, ptr); 661 668 662 669 return phy; 663 670 }
+11 -5
drivers/phy/phy-miphy28lp.c
··· 1226 1226 1227 1227 miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy), 1228 1228 GFP_KERNEL); 1229 - if (!miphy_phy) 1230 - return -ENOMEM; 1229 + if (!miphy_phy) { 1230 + ret = -ENOMEM; 1231 + goto put_child; 1232 + } 1231 1233 1232 1234 miphy_dev->phys[port] = miphy_phy; 1233 1235 1234 1236 phy = devm_phy_create(&pdev->dev, child, &miphy28lp_ops); 1235 1237 if (IS_ERR(phy)) { 1236 1238 dev_err(&pdev->dev, "failed to create PHY\n"); 1237 - return PTR_ERR(phy); 1239 + ret = PTR_ERR(phy); 1240 + goto put_child; 1238 1241 } 1239 1242 1240 1243 miphy_dev->phys[port]->phy = phy; ··· 1245 1242 1246 1243 ret = miphy28lp_of_probe(child, miphy_phy); 1247 1244 if (ret) 1248 - return ret; 1245 + goto put_child; 1249 1246 1250 1247 ret = miphy28lp_probe_resets(child, miphy_dev->phys[port]); 1251 1248 if (ret) 1252 - return ret; 1249 + goto put_child; 1253 1250 1254 1251 phy_set_drvdata(phy, miphy_dev->phys[port]); 1255 1252 port++; ··· 1258 1255 1259 1256 provider = devm_of_phy_provider_register(&pdev->dev, miphy28lp_xlate); 1260 1257 return PTR_ERR_OR_ZERO(provider); 1258 + put_child: 1259 + of_node_put(child); 1260 + return ret; 1261 1261 } 1262 1262 1263 1263 static const struct of_device_id miphy28lp_of_match[] = {
+11 -5
drivers/phy/phy-miphy365x.c
··· 566 566 567 567 miphy_phy = devm_kzalloc(&pdev->dev, sizeof(*miphy_phy), 568 568 GFP_KERNEL); 569 - if (!miphy_phy) 570 - return -ENOMEM; 569 + if (!miphy_phy) { 570 + ret = -ENOMEM; 571 + goto put_child; 572 + } 571 573 572 574 miphy_dev->phys[port] = miphy_phy; 573 575 574 576 phy = devm_phy_create(&pdev->dev, child, &miphy365x_ops); 575 577 if (IS_ERR(phy)) { 576 578 dev_err(&pdev->dev, "failed to create PHY\n"); 577 - return PTR_ERR(phy); 579 + ret = PTR_ERR(phy); 580 + goto put_child; 578 581 } 579 582 580 583 miphy_dev->phys[port]->phy = phy; 581 584 582 585 ret = miphy365x_of_probe(child, miphy_phy); 583 586 if (ret) 584 - return ret; 587 + goto put_child; 585 588 586 589 phy_set_drvdata(phy, miphy_dev->phys[port]); 587 590 ··· 594 591 &miphy_phy->ctrlreg); 595 592 if (ret) { 596 593 dev_err(&pdev->dev, "No sysconfig offset found\n"); 597 - return ret; 594 + goto put_child; 598 595 } 599 596 } 600 597 601 598 provider = devm_of_phy_provider_register(&pdev->dev, miphy365x_xlate); 602 599 return PTR_ERR_OR_ZERO(provider); 600 + put_child: 601 + of_node_put(child); 602 + return ret; 603 603 } 604 604 605 605 static const struct of_device_id miphy365x_of_match[] = {
+13 -7
drivers/phy/phy-mt65xx-usb3.c
··· 415 415 struct resource *sif_res; 416 416 struct mt65xx_u3phy *u3phy; 417 417 struct resource res; 418 - int port; 418 + int port, retval; 419 419 420 420 u3phy = devm_kzalloc(dev, sizeof(*u3phy), GFP_KERNEL); 421 421 if (!u3phy) ··· 447 447 for_each_child_of_node(np, child_np) { 448 448 struct mt65xx_phy_instance *instance; 449 449 struct phy *phy; 450 - int retval; 451 450 452 451 instance = devm_kzalloc(dev, sizeof(*instance), GFP_KERNEL); 453 - if (!instance) 454 - return -ENOMEM; 452 + if (!instance) { 453 + retval = -ENOMEM; 454 + goto put_child; 455 + } 455 456 456 457 u3phy->phys[port] = instance; 457 458 458 459 phy = devm_phy_create(dev, child_np, &mt65xx_u3phy_ops); 459 460 if (IS_ERR(phy)) { 460 461 dev_err(dev, "failed to create phy\n"); 461 - return PTR_ERR(phy); 462 + retval = PTR_ERR(phy); 463 + goto put_child; 462 464 } 463 465 464 466 retval = of_address_to_resource(child_np, 0, &res); 465 467 if (retval) { 466 468 dev_err(dev, "failed to get address resource(id-%d)\n", 467 469 port); 468 - return retval; 470 + goto put_child; 469 471 } 470 472 471 473 instance->port_base = devm_ioremap_resource(&phy->dev, &res); 472 474 if (IS_ERR(instance->port_base)) { 473 475 dev_err(dev, "failed to remap phy regs\n"); 474 - return PTR_ERR(instance->port_base); 476 + retval = PTR_ERR(instance->port_base); 477 + goto put_child; 475 478 } 476 479 477 480 instance->phy = phy; ··· 486 483 provider = devm_of_phy_provider_register(dev, mt65xx_phy_xlate); 487 484 488 485 return PTR_ERR_OR_ZERO(provider); 486 + put_child: 487 + of_node_put(child_np); 488 + return retval; 489 489 } 490 490 491 491 static const struct of_device_id mt65xx_u3phy_id_table[] = {
+12 -5
drivers/phy/phy-rockchip-usb.c
··· 108 108 109 109 for_each_available_child_of_node(dev->of_node, child) { 110 110 rk_phy = devm_kzalloc(dev, sizeof(*rk_phy), GFP_KERNEL); 111 - if (!rk_phy) 112 - return -ENOMEM; 111 + if (!rk_phy) { 112 + err = -ENOMEM; 113 + goto put_child; 114 + } 113 115 114 116 if (of_property_read_u32(child, "reg", &reg_offset)) { 115 117 dev_err(dev, "missing reg property in node %s\n", 116 118 child->name); 117 - return -EINVAL; 119 + err = -EINVAL; 120 + goto put_child; 118 121 } 119 122 120 123 rk_phy->reg_offset = reg_offset; ··· 130 127 rk_phy->phy = devm_phy_create(dev, child, &ops); 131 128 if (IS_ERR(rk_phy->phy)) { 132 129 dev_err(dev, "failed to create PHY\n"); 133 - return PTR_ERR(rk_phy->phy); 130 + err = PTR_ERR(rk_phy->phy); 131 + goto put_child; 134 132 } 135 133 phy_set_drvdata(rk_phy->phy, rk_phy); 136 134 137 135 /* only power up usb phy when it use, so disable it when init*/ 138 136 err = rockchip_usb_phy_power(rk_phy, 1); 139 137 if (err) 140 - return err; 138 + goto put_child; 141 139 } 142 140 143 141 phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate); 144 142 return PTR_ERR_OR_ZERO(phy_provider); 143 + put_child: 144 + of_node_put(child); 145 + return err; 145 146 } 146 147 147 148 static const struct of_device_id rockchip_usb_phy_dt_ids[] = {
+19 -3
drivers/usb/core/hub.c
··· 1035 1035 unsigned delay; 1036 1036 1037 1037 /* Continue a partial initialization */ 1038 - if (type == HUB_INIT2) 1039 - goto init2; 1040 - if (type == HUB_INIT3) 1038 + if (type == HUB_INIT2 || type == HUB_INIT3) { 1039 + device_lock(hub->intfdev); 1040 + 1041 + /* Was the hub disconnected while we were waiting? */ 1042 + if (hub->disconnected) { 1043 + device_unlock(hub->intfdev); 1044 + kref_put(&hub->kref, hub_release); 1045 + return; 1046 + } 1047 + if (type == HUB_INIT2) 1048 + goto init2; 1041 1049 goto init3; 1050 + } 1051 + kref_get(&hub->kref); 1042 1052 1043 1053 /* The superspeed hub except for root hub has to use Hub Depth 1044 1054 * value as an offset into the route string to locate the bits ··· 1246 1236 queue_delayed_work(system_power_efficient_wq, 1247 1237 &hub->init_work, 1248 1238 msecs_to_jiffies(delay)); 1239 + device_unlock(hub->intfdev); 1249 1240 return; /* Continues at init3: below */ 1250 1241 } else { 1251 1242 msleep(delay); ··· 1268 1257 /* Allow autosuspend if it was suppressed */ 1269 1258 if (type <= HUB_INIT3) 1270 1259 usb_autopm_put_interface_async(to_usb_interface(hub->intfdev)); 1260 + 1261 + if (type == HUB_INIT2 || type == HUB_INIT3) 1262 + device_unlock(hub->intfdev); 1263 + 1264 + kref_put(&hub->kref, hub_release); 1271 1265 } 1272 1266 1273 1267 /* Implement the continuations for the delays above */
+2 -1
drivers/usb/serial/ipaq.c
··· 531 531 * through. Since this has a reasonably high failure rate, we retry 532 532 * several times. 533 533 */ 534 - while (retries--) { 534 + while (retries) { 535 + retries--; 535 536 result = usb_control_msg(serial->dev, 536 537 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, 537 538 0x1, 0, NULL, 0, 100);