From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC071C433E6 for ; Mon, 20 Jul 2020 15:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C35322482 for ; Mon, 20 Jul 2020 15:49:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595260144; bh=0qTwDZ6Iw3dprPnwL8jchSVzMHxyLv0z21Gg6l59WME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=msT/H5k878fla3qFVVbPffCu0yKCyd1rWYEtA4VUGzMxdOMEQIf2bx41oHU7bEp2x S7xDp5jXcCa0Q6gY6d+F1O5kLbjOnN+8O60OTcHp95n0gyOrBIZmQMlGbi1O1dDpg2 K9Yoaf4O7vKusU/bzMLlRu92lD66EIJVJfWiYbDI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730965AbgGTPtD (ORCPT ); Mon, 20 Jul 2020 11:49:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:44904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730558AbgGTPtC (ORCPT ); Mon, 20 Jul 2020 11:49:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2BF042065E; Mon, 20 Jul 2020 15:49:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595260141; bh=0qTwDZ6Iw3dprPnwL8jchSVzMHxyLv0z21Gg6l59WME=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=za5pC8S448hxYtwXzl86fNLrmC+RW9b1lHvrA8zCy/vZQ6vI35p+iZiacDBrGIupr +/kK0KtiBMyP3d6+R9Si0Om/UyQCHVU5KZENXajhoZ0FGbG8aHvCSiOs4s+g5bGiHb fD8fPeddce30+WYvx0vHs2SimecniGP7jPSESx90= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miquel Raynal Subject: [PATCH 4.14 091/125] mtd: rawnand: oxnas: Keep track of registered devices Date: Mon, 20 Jul 2020 17:37:10 +0200 Message-Id: <20200720152807.416774732@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200720152802.929969555@linuxfoundation.org> References: <20200720152802.929969555@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Miquel Raynal commit 383fc3f613e7eac9f2e3c13b6f9fb8c1f39cb9d5 upstream. All initialized and registered devices should be listed somewhere so that we can unregister/free them in the _remove() path. This patch is not a fix per-se but is needed to apply three other fixes coming right after, explaining the Fixes/Cc: stable tags. Fixes: 668592492409 ("mtd: nand: Add OX820 NAND Support") Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20200519130035.1883-36-miquel.raynal@bootlin.com Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/oxnas_nand.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/mtd/nand/oxnas_nand.c +++ b/drivers/mtd/nand/oxnas_nand.c @@ -36,6 +36,7 @@ struct oxnas_nand_ctrl { void __iomem *io_base; struct clk *clk; struct nand_chip *chips[OXNAS_NAND_MAX_CHIPS]; + unsigned int nchips; }; static uint8_t oxnas_nand_read_byte(struct mtd_info *mtd) @@ -86,7 +87,6 @@ static int oxnas_nand_probe(struct platf struct nand_chip *chip; struct mtd_info *mtd; struct resource *res; - int nchips = 0; int count = 0; int err = 0; @@ -150,12 +150,12 @@ static int oxnas_nand_probe(struct platf if (err) goto err_cleanup_nand; - oxnas->chips[nchips] = chip; - ++nchips; + oxnas->chips[oxnas->nchips] = chip; + ++oxnas->nchips; } /* Exit if no chips found */ - if (!nchips) { + if (!oxnas->nchips) { err = -ENODEV; goto err_clk_unprepare; }