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

misc: rtsx: Fix an error handling path in rtsx_pci_probe()

If an error occurs after a successful idr_alloc() call, the corresponding
resource must be released with idr_remove() as already done in the .remove
function.

Update the error handling path to add the missing idr_remove() call.

Fixes: ada8a8a13b13 ("mfd: Add realtek pcie card reader driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/e8dc41716cbf52fb37a12e70d8972848e69df6d6.1655271216.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
44fd1917 9864bb48

+5 -1
+5 -1
drivers/misc/cardreader/rtsx_pcr.c
··· 1507 1507 pcr->remap_addr = ioremap(base, len); 1508 1508 if (!pcr->remap_addr) { 1509 1509 ret = -ENOMEM; 1510 - goto free_handle; 1510 + goto free_idr; 1511 1511 } 1512 1512 1513 1513 pcr->rtsx_resv_buf = dma_alloc_coherent(&(pcidev->dev), ··· 1570 1570 pcr->rtsx_resv_buf, pcr->rtsx_resv_buf_addr); 1571 1571 unmap: 1572 1572 iounmap(pcr->remap_addr); 1573 + free_idr: 1574 + spin_lock(&rtsx_pci_lock); 1575 + idr_remove(&rtsx_pci_idr, pcr->id); 1576 + spin_unlock(&rtsx_pci_lock); 1573 1577 free_handle: 1574 1578 kfree(handle); 1575 1579 free_pcr: