Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9091089pxu; Mon, 28 Dec 2020 06:25:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxewQOntXa1I9jIoQgvWiRDn54QPmyrfDK/bl/zh4IFdrTFVQ1sNHl5Cb61rX/pIVLVmcwq X-Received: by 2002:a05:6402:45:: with SMTP id f5mr42160594edu.273.1609165514022; Mon, 28 Dec 2020 06:25:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165514; cv=none; d=google.com; s=arc-20160816; b=BRdP10T/mL9TlMfjHFEiFiYiuGz/bxU2h7bMBPvPprnY2NLnrgyMCy2I0qWOp1Cjgq Q1keZZEJjwUuH1ExKlR5hvP0OQK/FbFUXdz4TXsP3FMtFwbVlN202FaLngMtZhZC0YB6 ljD3wB9DwNaKkM/en1QG9Uv55fKo8Ur6oTxWvjKdZVmJDrS9U+JgzxokzGkd41aKHB1Z 9nZj5MI7fgnvIJAMEiVc9Ph6MEwF1JTIMmRt21Q2NDwI0evCFlCrQkkNukhkefhi8qU8 VdxtyGnB/Q39J1b7dofEI0lLB0gYS2UM0XA2hDhZ5U4134zYsPnJKszo7g4A0avu9pPL Y8iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VPockU7WNeddSz/+osPjdFEu3sUIQc4trBPbEa+cXHQ=; b=Ui3407dC1akQyUWd+ab3lu2XAwEbTAOJppa6vpZuPbLLX2EBOnczwb1BRpQqaJOwhr Fi7Mu57ykVbemSfK9PYPVJdS8AnMLjVFw648azHIuOWFqPoofa72DwvJs/wdPDnJaWNj wRWtxLuV77sjFiYMUmNHVr+GoY8EEG8YqhormHghGWO5CMRy+rgkx4Wi52c0VOVcRadB qQ8Q58orC1z0ZkvAcXwN7qh1FcjCzmAU7fTKXTsTMjIJ0S4qo5QZ6fM5n5XgzRS0294d iGcoidJanZTUBGuN6OAeGWFgi+/5kFuZEUqqKjzVyDuM/KdPlV7VYs9KtPhEggi32LZX 8c5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tgtXhe8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u32si20545124edc.94.2020.12.28.06.24.51; Mon, 28 Dec 2020 06:25:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tgtXhe8g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437864AbgL1OUy (ORCPT + 99 others); Mon, 28 Dec 2020 09:20:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:56138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437823AbgL1OUt (ORCPT ); Mon, 28 Dec 2020 09:20:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 93B77229C4; Mon, 28 Dec 2020 14:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165203; bh=6DMu6UVT5XY11l7laUZ2NODoQR8Y7FJqYKfynL9wG98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgtXhe8gXTCMiDkhJgGFXUCCA3e9j1hPD0AUjPTge3Se7lWb+I5YSTBAAy8zbLnoG zbQ1n7ZUfHZZXpagj3td+tOCcvc+d6o1MKCXaJzl6+uNX2bVQMVGv7f2TJQSz5vy0z +llml9ctvJai+L4HEbxTkpyVZdt1CZPrIB5gEmyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Han Xu , Miquel Raynal , Sasha Levin Subject: [PATCH 5.10 408/717] mtd: rawnand: gpmi: fix reference count leak in gpmi ops Date: Mon, 28 Dec 2020 13:46:46 +0100 Message-Id: <20201228125040.528779957@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong [ Upstream commit 1b391c7f2e863985668d705f525af3ceb55bc800 ] pm_runtime_get_sync() will increment pm usage at first and it will resume the device later. If runtime of the device has error or device is in inaccessible state(or other error state), resume operation will fail. If we do not call put operation to decrease the reference, it will result in reference leak in the two functions(gpmi_init and gpmi_nfc_exec_op). Moreover, this device cannot enter the idle state and always stay busy or other non-idle state later. So we fixed it through adding pm_runtime_put_noidle. Fixes: 5bc6bb603b4d0 ("mtd: rawnand: gpmi: Fix suspend/resume problem") Signed-off-by: Zhang Qilong Acked-by: Han Xu Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20201107110552.1568742-1-zhangqilong3@huawei.com Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index dc8104e675062..b5f46f214a582 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -149,8 +149,10 @@ static int gpmi_init(struct gpmi_nand_data *this) int ret; ret = pm_runtime_get_sync(this->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(this->dev); return ret; + } ret = gpmi_reset_block(r->gpmi_regs, false); if (ret) @@ -2263,8 +2265,10 @@ static int gpmi_nfc_exec_op(struct nand_chip *chip, this->transfers[i].direction = DMA_NONE; ret = pm_runtime_get_sync(this->dev); - if (ret < 0) + if (ret < 0) { + pm_runtime_put_noidle(this->dev); return ret; + } /* * This driver currently supports only one NAND chip. Plus, dies share -- 2.27.0