lkml.org 
[lkml]   [2011]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH next 4/6] staging: crystalhd: fix memory leaks
    Date
    Free resources before exit.

    Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
    ---
    drivers/staging/crystalhd/crystalhd_hw.c | 1 +
    drivers/staging/crystalhd/crystalhd_lnx.c | 18 +++++++++++++-----
    2 files changed, 14 insertions(+), 5 deletions(-)

    diff --git a/drivers/staging/crystalhd/crystalhd_hw.c b/drivers/staging/crystalhd/crystalhd_hw.c
    index 153ddbf..13a514d 100644
    --- a/drivers/staging/crystalhd/crystalhd_hw.c
    +++ b/drivers/staging/crystalhd/crystalhd_hw.c
    @@ -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;
    diff --git a/drivers/staging/crystalhd/crystalhd_lnx.c b/drivers/staging/crystalhd/crystalhd_lnx.c
    index 719e70b..2b47ef9 100644
    --- a/drivers/staging/crystalhd/crystalhd_lnx.c
    +++ b/drivers/staging/crystalhd/crystalhd_lnx.c
    @@ -561,7 +561,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, 31, "crystalhd_pci_e:%d:%d:%d",
    @@ -572,7 +572,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;
    @@ -587,7 +588,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... */
    @@ -600,14 +602,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);
    @@ -617,6 +621,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
    --
    1.7.4.1


    \
     
     \ /
      Last update: 2011-03-10 03:47    [W:0.074 / U:0.360 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site