From patchwork Fri May 8 12:32:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226100 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,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 A0FADC38A2A for ; Fri, 8 May 2020 13:19:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7ED72206B9 for ; Fri, 8 May 2020 13:19:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588943989; bh=q+u+Ooo9X2BXKnDKEMm+z9vr/5/zeJ8JyneIAjRTENw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=l+7srZAd58gUPRYcfB05limkzV3dHVX8OjiucR1cNjb19spCw7XQlt3Spk4scopjp pCxpw5EKI4X1HOwz8gfl+P8DdQWoQIBpwjXm0kLFI+lFoG6GH0TFf3ASkV8ycz6gZD M9JULym/6C73bwvAE+ADGWwg+mEmZg4mGBm0hahU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727801AbgEHMlf (ORCPT ); Fri, 8 May 2020 08:41:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:36534 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbgEHMla (ORCPT ); Fri, 8 May 2020 08:41:30 -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 C5E3920731; Fri, 8 May 2020 12:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588941690; bh=q+u+Ooo9X2BXKnDKEMm+z9vr/5/zeJ8JyneIAjRTENw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aBMcBpAQvem86GY7eGEZ5UG7KC9d424dJQiwHHhX0uy7v9s6bIbme/4Y8pS4zLowx 46ruUVAhRyimysOWXrppNES2r0wh4pPXeF5GXHD+UGwhXq+MF0oovEwMhuZuWLPhc/ KsUyAcM1KQkaZeA1rGa66X+xBADe24waHm7tohMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Boris Brezillon , Dinh Nguyen , Brian Norris Subject: [PATCH 4.4 132/312] mtd: nand: denali: add missing nand_release() call in denali_remove() Date: Fri, 8 May 2020 14:32:03 +0200 Message-Id: <20200508123133.790481132@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200508123124.574959822@linuxfoundation.org> References: <20200508123124.574959822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Boris Brezillon commit 320092a05dab2f44819c42f33d6b51efb6c474f2 upstream. Unregister the NAND device from the NAND subsystem when removing a denali NAND controller, otherwise the MTD attached to the NAND device is still exposed by the MTD layer, and accesses to this device will likely crash the system. Fixes: 2a0a288ec258 ("mtd: denali: split the generic driver and PCI layer") Signed-off-by: Boris Brezillon Acked-by: Dinh Nguyen Signed-off-by: Brian Norris Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/denali.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -1622,9 +1622,16 @@ EXPORT_SYMBOL(denali_init); /* driver exit point */ void denali_remove(struct denali_nand_info *denali) { + /* + * Pre-compute DMA buffer size to avoid any problems in case + * nand_release() ever changes in a way that mtd->writesize and + * mtd->oobsize are not reliable after this call. + */ + int bufsize = denali->mtd.writesize + denali->mtd.oobsize; + + nand_release(&denali->mtd); denali_irq_cleanup(denali->irq, denali); - dma_unmap_single(denali->dev, denali->buf.dma_buf, - denali->mtd.writesize + denali->mtd.oobsize, + dma_unmap_single(denali->dev, denali->buf.dma_buf, bufsize, DMA_BIDIRECTIONAL); } EXPORT_SYMBOL(denali_remove);