lkml.org 
[lkml]   [2018]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 76/86] scsi: ufshcd: release resources if probe fails
    Date
    4.4-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Subhash Jadavani <subhashj@codeaurora.org>

    commit afa3dfd42d205b106787476647735aa1de1a5d02 upstream.

    If ufshcd pltfrm/pci driver's probe fails for some reason then ensure
    that scsi host is released to avoid memory leak but managed memory
    allocations (via devm_* calls) need not to be freed explicitly on probe
    failure as memory allocated with these functions is automatically freed
    on driver detach.

    Reviewed-by: Sahitya Tummala <stummala@codeaurora.org>
    Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/scsi/ufs/ufshcd-pci.c | 2 ++
    drivers/scsi/ufs/ufshcd-pltfrm.c | 5 +----
    drivers/scsi/ufs/ufshcd.c | 3 ---
    3 files changed, 3 insertions(+), 7 deletions(-)

    --- a/drivers/scsi/ufs/ufshcd-pci.c
    +++ b/drivers/scsi/ufs/ufshcd-pci.c
    @@ -104,6 +104,7 @@ static void ufshcd_pci_remove(struct pci
    pm_runtime_forbid(&pdev->dev);
    pm_runtime_get_noresume(&pdev->dev);
    ufshcd_remove(hba);
    + ufshcd_dealloc_host(hba);
    }

    /**
    @@ -147,6 +148,7 @@ ufshcd_pci_probe(struct pci_dev *pdev, c
    err = ufshcd_init(hba, mmio_base, pdev->irq);
    if (err) {
    dev_err(&pdev->dev, "Initialization failed\n");
    + ufshcd_dealloc_host(hba);
    return err;
    }

    --- a/drivers/scsi/ufs/ufshcd-pltfrm.c
    +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
    @@ -161,7 +161,7 @@ static int ufshcd_populate_vreg(struct d
    if (ret) {
    dev_err(dev, "%s: unable to find %s err %d\n",
    __func__, prop_name, ret);
    - goto out_free;
    + goto out;
    }

    vreg->min_uA = 0;
    @@ -183,9 +183,6 @@ static int ufshcd_populate_vreg(struct d

    goto out;

    -out_free:
    - devm_kfree(dev, vreg);
    - vreg = NULL;
    out:
    if (!ret)
    *out_vreg = vreg;
    --- a/drivers/scsi/ufs/ufshcd.c
    +++ b/drivers/scsi/ufs/ufshcd.c
    @@ -5385,8 +5385,6 @@ void ufshcd_remove(struct ufs_hba *hba)
    ufshcd_disable_intr(hba, hba->intr_mask);
    ufshcd_hba_stop(hba);

    - scsi_host_put(hba->host);
    -
    ufshcd_exit_clk_gating(hba);
    if (ufshcd_is_clkscaling_enabled(hba))
    devfreq_remove_device(hba->devfreq);
    @@ -5733,7 +5731,6 @@ exit_gating:
    ufshcd_exit_clk_gating(hba);
    out_disable:
    hba->is_irq_enabled = false;
    - scsi_host_put(host);
    ufshcd_hba_exit(hba);
    out_error:
    return err;

    \
     
     \ /
      Last update: 2018-11-29 15:58    [W:4.220 / U:0.144 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site