Received: by 10.192.165.156 with SMTP id m28csp1117999imm; Wed, 11 Apr 2018 12:46:57 -0700 (PDT) X-Google-Smtp-Source: AIpwx49/r6mIHvMBLvpIaSIMmgEk7ybwwKkzA0duLKVtDrmHxwSo72Slo7uWkRfX23DMj3ImkMPr X-Received: by 10.98.66.203 with SMTP id h72mr5126885pfd.156.1523476017195; Wed, 11 Apr 2018 12:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523476017; cv=none; d=google.com; s=arc-20160816; b=h0SflJMN9X8xgHbRYn23H1uYTzNPVybKyuw3RVnhGUx0FOtL1Qo18JJJNxwr21oXlC xpX1Xj5hMQMLCwbLOU+uD9wiGvgSFjrHXV6vgJonC6QlOMEjnuQlrcSx/qhEAhQfkDIj EemQ/j83Grzdk8VmgrxxkDNvBKLUCGtuVPhX1d4NYRfyptOsszpt612j/K4hNhN8bKxR aJG+KJh72nZ6i6TjVffQ++edll1stmLdnbgcbiFxAgmy0BKZpxjpfRSWyPWisn57R8RV ZcJ8tfQpoV6CnjyJMkBJTVDPoku89773ksxm/W7unjtgsWSyJ9czeAkRHOLSr8Pfyp/A viNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=QMp4atpLVoWIY/Gtno4AcdCJhcV3f7coDNIwyb/NL6c=; b=WE8MOrnoZ7FRS0m+2KorzqhPz5pd8lIXrtEjnBMLCx+MPH0LibQw0oe6Bms/T581/8 WNM/3EiCNWCvPbBZKFLFhjg1BQZFWrTopigYbLZYMjzVht0DlCoogN06y6Qyq+qX/9Jd hiZvNNaft86K5OT4yM4EGEKaEAW+UZOHwxGO0Z95MRy2ufNftaNv2e67jOijfH1zhNpl n4aCSx8p9dLbvXonmwv5cUmGzoM7Xy3+QCicCntHEzW6SFMkAtmjUXwPGwtqmj9BqElS nFAPU2UWUGktF5zy98G7L+VFYmFD5em8NhrMUAncCYIv6SzxUbD6hdSZ/g4+JV81yUyM Jj+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y11-v6si1722985plg.154.2018.04.11.12.46.20; Wed, 11 Apr 2018 12:46:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757117AbeDKTna (ORCPT + 99 others); Wed, 11 Apr 2018 15:43:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37756 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756708AbeDKTA0 (ORCPT ); Wed, 11 Apr 2018 15:00:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 52FF3D61; Wed, 11 Apr 2018 19:00:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Brezillon , Marek Vasut , Han Xu , Sasha Levin Subject: [PATCH 4.9 169/310] mtd: nand: gpmi: Fix gpmi_nand_init() error path Date: Wed, 11 Apr 2018 20:35:08 +0200 Message-Id: <20180411183629.881965851@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Boris Brezillon [ Upstream commit 4d02423e9afe6c46142ce98bbcaf5167316dbfbf ] The GPMI driver is wrongly assuming that nand_release() can safely be called on an uninitialized/unregistered NAND device. Add a new err_nand_cleanup label in the error path and only execute if nand_scan_tail() succeeded. Note that we now call nand_cleanup() instead of nand_release() (nand_release() is actually grouping the mtd_device_unregister() and nand_cleanup() in one call) because there's no point in trying to unregister a device that has never been registered. Signed-off-by: Boris Brezillon Reviewed-by: Marek Vasut Acked-by: Han Xu Reviewed-by: Marek Vasut Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -2047,18 +2047,20 @@ static int gpmi_nand_init(struct gpmi_na ret = nand_boot_init(this); if (ret) - goto err_out; + goto err_nand_cleanup; ret = chip->scan_bbt(mtd); if (ret) - goto err_out; + goto err_nand_cleanup; ret = mtd_device_register(mtd, NULL, 0); if (ret) - goto err_out; + goto err_nand_cleanup; return 0; +err_nand_cleanup: + nand_cleanup(chip); err_out: - gpmi_nand_exit(this); + gpmi_free_dma_buffer(this); return ret; }