All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Pundir <amit.pundir@linaro.org>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: Stable <stable@vger.kernel.org>,
	Subhash Jadavani <subhashj@codeaurora.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: [PATCH for-4.9.y 10/10] scsi: ufshcd: release resources if probe fails
Date: Wed, 28 Nov 2018 20:10:04 +0530	[thread overview]
Message-ID: <1543416004-1547-11-git-send-email-amit.pundir@linaro.org> (raw)
In-Reply-To: <1543416004-1547-1-git-send-email-amit.pundir@linaro.org>

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>
---
 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(-)

diff --git a/drivers/scsi/ufs/ufshcd-pci.c b/drivers/scsi/ufs/ufshcd-pci.c
index d15eaa466c59..52b546fb509b 100644
--- 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_dev *pdev)
 	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, const struct pci_device_id *id)
 	err = ufshcd_init(hba, mmio_base, pdev->irq);
 	if (err) {
 		dev_err(&pdev->dev, "Initialization failed\n");
+		ufshcd_dealloc_host(hba);
 		return err;
 	}
 
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index db53f38da864..a72a4ba78125 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -163,7 +163,7 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 	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;
@@ -185,9 +185,6 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
 
 	goto out;
 
-out_free:
-	devm_kfree(dev, vreg);
-	vreg = NULL;
 out:
 	if (!ret)
 		*out_vreg = vreg;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 39732e93d460..5cfd56f08ffb 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6507,8 +6507,6 @@ void ufshcd_remove(struct ufs_hba *hba)
 	ufshcd_disable_intr(hba, hba->intr_mask);
 	ufshcd_hba_stop(hba, true);
 
-	scsi_host_put(hba->host);
-
 	ufshcd_exit_clk_gating(hba);
 	if (ufshcd_is_clkscaling_enabled(hba))
 		devfreq_remove_device(hba->devfreq);
@@ -6876,7 +6874,6 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
 	ufshcd_exit_clk_gating(hba);
 out_disable:
 	hba->is_irq_enabled = false;
-	scsi_host_put(host);
 	ufshcd_hba_exit(hba);
 out_error:
 	return err;
-- 
2.7.4

  parent reply	other threads:[~2018-11-29  1:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 14:39 [PATCH for-4.9.y 00/10] Stable candidates for linux-4.9.y Amit Pundir
2018-11-28 14:39 ` [PATCH for-4.9.y 01/10] ath10k: fix kernel panic due to race in accessing arvif list Amit Pundir
2018-11-28 14:39 ` [PATCH for-4.9.y 02/10] cw1200: Don't leak memory if krealloc failes Amit Pundir
2018-11-28 14:39 ` [PATCH for-4.9.y 03/10] mwifiex: prevent register accesses after host is sleeping Amit Pundir
2018-11-28 14:39 ` [PATCH for-4.9.y 04/10] mwifiex: report error to PCIe for suspend failure Amit Pundir
2018-11-28 14:39 ` [PATCH for-4.9.y 05/10] mwifiex: Fix NULL pointer dereference in skb_dequeue() Amit Pundir
2018-11-28 14:40 ` [PATCH for-4.9.y 06/10] mwifiex: fix p2p device doesn't find in scan problem Amit Pundir
2018-11-28 14:40 ` [PATCH for-4.9.y 07/10] scsi: ufs: fix bugs related to null pointer access and array size Amit Pundir
2018-11-28 14:40 ` [PATCH for-4.9.y 08/10] scsi: ufshcd: Fix race between clk scaling and ungate work Amit Pundir
2018-11-28 14:40 ` [PATCH for-4.9.y 09/10] scsi: ufs: fix race between clock gating and devfreq scaling work Amit Pundir
2018-11-28 14:40 ` Amit Pundir [this message]
2018-11-29 10:12 ` [PATCH for-4.9.y 00/10] Stable candidates for linux-4.9.y Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1543416004-1547-11-git-send-email-amit.pundir@linaro.org \
    --to=amit.pundir@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=martin.petersen@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=subhashj@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.