From patchwork Wed Nov 28 17:29:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 152335 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1365438ljp; Wed, 28 Nov 2018 09:29:51 -0800 (PST) X-Google-Smtp-Source: AJdET5dcqLTL1UsjQa+fLygtKZp38HJ5pDot8HonrGixGqe3PldAZ4c225evzuEjarlW+OsYKndb X-Received: by 2002:a62:1bd7:: with SMTP id b206mr38206324pfb.213.1543426191332; Wed, 28 Nov 2018 09:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543426191; cv=none; d=google.com; s=arc-20160816; b=hEfombqF6VHmbz668M7K6sOKCBFBoPs2Ns9fuy3+KBbRmFRf89O3VaowiuXIiokbbO 3BrANEW3Y0gV+sg0AceU2uaCRZcAuPqBBAbkKti3FOIaUiqL0sE4bWnOv+5bQCCqjWwS jkXgaOdQzLRa7jFXlE7Mfc7P/KJZEt68EPog6sKGrv37BcUztjNLlWD0takc+6TjP93x tN4vVYMbzecIhJGxUL7eYxf1NncVDiLPiOc7lvNe2f2dlgbBgYlonWtMhOPj4oNBuAmJ fOVa4LngnfLIgUBMcL+DMiiRF81a5rwJE6CSyY9bIOVwA/OGWZ+k19LWAR+RKhWDzguQ /BgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=oNfle6BJJL/abhwvbAjuPo0YAKVv6bEVgWcrMpvab24=; b=GT2+gjMKLg00JVErqwv6lJH5BSgh1qBnbZ9xN5BkoVMODMoQDhhdP65dgI+LZkBygC RZdDsvZlT1MAB3GrZR41Pa6zkkpoKpuRqTuJky+xRONA3VfZA0A700gMBKhmHl/NdBif vmMZKjXpwTLPAlo/f/RtvSItnjgUPQuFH4kmzz91A7EKoQZkhDOz6/R9jUFVchldBRin rti7gDKzNUwYLhiHaem6M4EtJyAHAESoDk+yADMZZkgokqp88uzVoYvgBfy4nBigF01I vu4pwdZ2Qxwe691HSQMPlHm6M5vaPXEZnuomghUl+e/grNbm92nT2LS3C0dHTSvZ1aqv tq7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NwPrWMn2; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 44si8357481plb.57.2018.11.28.09.29.49; Wed, 28 Nov 2018 09:29:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NwPrWMn2; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729263AbeK2Eb7 (ORCPT + 15 others); Wed, 28 Nov 2018 23:31:59 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43808 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728851AbeK2Eb6 (ORCPT ); Wed, 28 Nov 2018 23:31:58 -0500 Received: by mail-pg1-f195.google.com with SMTP id v28so9785962pgk.10 for ; Wed, 28 Nov 2018 09:29:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oNfle6BJJL/abhwvbAjuPo0YAKVv6bEVgWcrMpvab24=; b=NwPrWMn2Itq4uIjI4cCgsOmopK9HygdkwogSYSMmetqASCV1F17MwgHz4Fh3xnF2Lc V2rc/cSwfkBxToDe+tEjYctdqpHWfpQTZM2SG4zfFe+ZE2q9YgyLgWev2kJXJsFuENCx YzdcfdLhueGSWf9RXSvfCU6BJMyHr4+/BB05k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oNfle6BJJL/abhwvbAjuPo0YAKVv6bEVgWcrMpvab24=; b=GcvLZXJ5B+uvXcyOpCqAELd+4S1GzsjTkXYr5ajAa/M2oOk8XPiYZAiD7cK1dcmSRc ElkauyCJGd/28uIsL2kZMnbK6kM6FiG6T0mah9y5KImYf3L5QPfReBTnW6O7xsNXaiTl ZTLZteTCfl7Dj/B1bhDXU72k4WmPscu7plo/I2IIabA93Cpdannxvf4chjdhZMaCggnQ 8YJGCK/+nIiuT5s/DFiruTwhZO2OSY7mmwr4NPWIMIF7vxcPiFn2uFO7Y+1umHaDO3G3 7S8+y/3UFM6gB+nInzJp7IBA/3WRjzwobx3Xf4p1E2C/gYrY8W8yNsku3VlnlP21yyzG dOtA== X-Gm-Message-State: AA+aEWZ1DGqR+H1RSANU6b5qitP7AOxYVm39UaVtUQcC3kmAj04gSqTo uPPt+RwDfAh0B16N6B2JeGJiIg== X-Received: by 2002:a63:680a:: with SMTP id d10mr34279888pgc.396.1543426175145; Wed, 28 Nov 2018 09:29:35 -0800 (PST) Received: from localhost.localdomain ([49.207.53.6]) by smtp.gmail.com with ESMTPSA id 84sm13624360pfk.134.2018.11.28.09.29.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Nov 2018 09:29:34 -0800 (PST) From: Amit Pundir To: Greg KH Cc: Stable , Subhash Jadavani , "Martin K . Petersen" Subject: [PATCH for-4.4.y 08/10] scsi: ufshcd: release resources if probe fails Date: Wed, 28 Nov 2018 22:59:07 +0530 Message-Id: <1543426149-7269-9-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543426149-7269-1-git-send-email-amit.pundir@linaro.org> References: <1543426149-7269-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Subhash Jadavani 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 Signed-off-by: Subhash Jadavani Signed-off-by: Martin K. Petersen [AmitP: Rebased for linux-4.4.y] Signed-off-by: Amit Pundir --- 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(-) -- 2.7.4 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 9714f2a8b329..f58abfcdfe81 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -161,7 +161,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; @@ -183,9 +183,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 7e6ba17d61f8..c94d465de941 100644 --- 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;