Skip to content

Commit

Permalink
staging: crystalhd: fix memory leaks
Browse files Browse the repository at this point in the history
Free resources before exit.

Signed-off-by: Alexander Beregalov <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
alexb0 authored and gregkh committed Mar 14, 2011
1 parent 819d4eb commit b4c7784
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions drivers/staging/crystalhd/crystalhd_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,7 @@ enum BC_STATUS crystalhd_hw_setup_dma_rings(struct crystalhd_hw *hw)
} else {
BCMLOG_ERR("Insufficient Memory For RX\n");
crystalhd_hw_free_dma_rings(hw);
kfree(rpkt);
return BC_STS_INSUFF_RES;
}
rpkt->desc_mem.pdma_desc_start = mem;
Expand Down
18 changes: 13 additions & 5 deletions drivers/staging/crystalhd/crystalhd_lnx.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
rc = pci_enable_device(pdev);
if (rc) {
BCMLOG_ERR("Failed to enable PCI device\n");
return rc;
goto err;
}

snprintf(pinfo->name, sizeof(pinfo->name), "crystalhd_pci_e:%d:%d:%d",
Expand All @@ -570,7 +570,8 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
if (rc) {
BCMLOG_ERR("Failed to setup memory regions.\n");
pci_disable_device(pdev);
return -ENOMEM;
rc = -ENOMEM;
goto err;
}

pinfo->present = 1;
Expand All @@ -585,7 +586,8 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
if (rc) {
BCMLOG_ERR("_enable_int err:%d\n", rc);
pci_disable_device(pdev);
return -ENODEV;
rc = -ENODEV;
goto err;
}

/* Set dma mask... */
Expand All @@ -598,14 +600,16 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
} else {
BCMLOG_ERR("Unabled to setup DMA %d\n", rc);
pci_disable_device(pdev);
return -ENODEV;
rc = -ENODEV;
goto err;
}

sts = crystalhd_setup_cmd_context(&pinfo->cmds, pinfo);
if (sts != BC_STS_SUCCESS) {
BCMLOG_ERR("cmd setup :%d\n", sts);
pci_disable_device(pdev);
return -ENODEV;
rc = -ENODEV;
goto err;
}

pci_set_master(pdev);
Expand All @@ -615,6 +619,10 @@ static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
g_adp_info = pinfo;

return 0;

err:
kfree(pinfo);
return rc;
}

#ifdef CONFIG_PM
Expand Down

0 comments on commit b4c7784

Please sign in to comment.