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 'ata-6.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata

Pull ata fixes from Damien Le Moal:

- Two fixes from Ondrej for the pata_parport driver to address an issue
with error handling during drive connection and to fix memory leaks
in case of errors during initialization and when disconnecting a
device.

* tag 'ata-6.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata:
ata: pata_parport: fix memory leaks
ata: pata_parport: fix parport release without claim

+18 -14
+18 -14
drivers/ata/pata_parport/pata_parport.c
··· 381 381 { 382 382 struct pi_adapter *pi = container_of(dev, struct pi_adapter, dev); 383 383 384 + ida_free(&pata_parport_bus_dev_ids, dev->id); 384 385 kfree(pi); 385 386 } 386 387 ··· 434 433 if (bus_for_each_dev(&pata_parport_bus_type, NULL, &match, pi_find_dev)) 435 434 return NULL; 436 435 437 - pi = kzalloc(sizeof(struct pi_adapter), GFP_KERNEL); 438 - if (!pi) 436 + id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL); 437 + if (id < 0) 439 438 return NULL; 439 + 440 + pi = kzalloc(sizeof(struct pi_adapter), GFP_KERNEL); 441 + if (!pi) { 442 + ida_free(&pata_parport_bus_dev_ids, id); 443 + return NULL; 444 + } 440 445 441 446 /* set up pi->dev before pi_probe_unit() so it can use dev_printk() */ 442 447 pi->dev.parent = &pata_parport_bus; 443 448 pi->dev.bus = &pata_parport_bus_type; 444 449 pi->dev.driver = &pr->driver; 445 450 pi->dev.release = pata_parport_dev_release; 446 - id = ida_alloc(&pata_parport_bus_dev_ids, GFP_KERNEL); 447 - if (id < 0) 448 - return NULL; /* pata_parport_dev_release will do kfree(pi) */ 449 451 pi->dev.id = id; 450 452 dev_set_name(&pi->dev, "pata_parport.%u", pi->dev.id); 451 453 if (device_register(&pi->dev)) { 452 454 put_device(&pi->dev); 453 - goto out_ida_free; 455 + /* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */ 456 + return NULL; 454 457 } 455 458 456 459 pi->proto = pr; ··· 469 464 pi->port = parport->base; 470 465 471 466 par_cb.private = pi; 472 - pi->pardev = parport_register_dev_model(parport, DRV_NAME, &par_cb, 473 - pi->dev.id); 467 + pi->pardev = parport_register_dev_model(parport, DRV_NAME, &par_cb, id); 474 468 if (!pi->pardev) 475 469 goto out_module_put; 476 470 ··· 491 487 492 488 pi_connect(pi); 493 489 if (ata_host_activate(host, 0, NULL, 0, &pata_parport_sht)) 494 - goto out_unreg_parport; 490 + goto out_disconnect; 495 491 496 492 return pi; 497 493 498 - out_unreg_parport: 494 + out_disconnect: 499 495 pi_disconnect(pi); 496 + out_unreg_parport: 500 497 parport_unregister_device(pi->pardev); 501 498 if (pi->proto->release_proto) 502 499 pi->proto->release_proto(pi); ··· 505 500 module_put(pi->proto->owner); 506 501 out_unreg_dev: 507 502 device_unregister(&pi->dev); 508 - out_ida_free: 509 - ida_free(&pata_parport_bus_dev_ids, pi->dev.id); 503 + /* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */ 510 504 return NULL; 511 505 } 512 506 ··· 630 626 pi_disconnect(pi); 631 627 pi_release(pi); 632 628 device_unregister(dev); 633 - ida_free(&pata_parport_bus_dev_ids, dev->id); 634 - /* pata_parport_dev_release will do kfree(pi) */ 629 + /* pata_parport_dev_release will do ida_free(dev->id) and kfree(pi) */ 635 630 } 636 631 637 632 static ssize_t delete_device_store(struct bus_type *bus, const char *buf, ··· 646 643 } 647 644 648 645 pi_remove_one(dev); 646 + put_device(dev); 649 647 mutex_unlock(&pi_mutex); 650 648 651 649 return count;