Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4607356pxj; Wed, 12 May 2021 09:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa/foA7mNTg2S1D10TJ5YpJ5yrrXMuag71t7FsAux0Wimu7wPc55o/inFSkxlkumxAfrJ8 X-Received: by 2002:aa7:d58b:: with SMTP id r11mr637092edq.231.1620835712018; Wed, 12 May 2021 09:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835712; cv=none; d=google.com; s=arc-20160816; b=YqngWJ3h5O1nD7+dnwLvYYQoYoxfdZS/7UYXlPdIvUWSTeGSOKbHuclU5klBLPTm4G Clc/Nust4fyc5wDbtAhqr/GEepEtjF62M9u8zYrXV/URL169izVy/NNzxZPJDg0cYQbQ wDJ8gME04qKRQLeNV5wsbYeTjdU/wvp8cGlzKLOznC9T+vsoHlBATkfoQoUPA14Iq+3b TLj75lLPB22ELrDNQ0efWfc1t0q8yCNSIHN0U1QsA6/1dciTrW80q1VDG23jI3E/FlJH HUm++ksyThCuxu2eUwt9QaaY0dsAVg+HsDAIix2z2nnYEgasphZ3xO4XpgKhrPcRZbCD b6Fg== 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=w8jPGiHIHBs0StWhJtRe7P6xSMDZkFAynly19vu+8u0=; b=OnUiY7km2Vm8C/jbNvVmWpd6yxvU/Mt428j4eZvVFXQCKpBZTHnra3Ksercj9IUG5y Hh8x6ybjfw56R+UZ71duiQQLiVU885UlBCCuaFzZy376Eq1kQ48pa9m+pBfvuwzpOk7k gyCDjjKREdUwHveATtUIC1LOhbZ5MAkfClkrmrFynpirDZTD18eXkGgqtg3ZgH55xYCL l9UExGoE4TPCelzq/oPo6f01uJYSaoJvKestgs9P8OFp4MyPMcMdwQaEK8UzPsto/TQ3 A7kj0z6dLfnYwnUMt+WKnv8rqbMZaOsIRFzdMffPKU1H4z9OGA3+AOdcCFBLkm7rgIz+ 8F0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ns9KF8dg; 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 q1si328394ejy.298.2021.05.12.09.08.08; Wed, 12 May 2021 09:08:32 -0700 (PDT) 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=ns9KF8dg; 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 S238858AbhELQGj (ORCPT + 99 others); Wed, 12 May 2021 12:06:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:38784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234922AbhELPZz (ORCPT ); Wed, 12 May 2021 11:25:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2098161624; Wed, 12 May 2021 15:11:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832261; bh=npQCIwNStazw1sJVTG8Qiw94f0ErD9eXbLG2sP3lqwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ns9KF8dgysb9L9v0WdDUTh1ZAPMa7LLWQU6ys+b4ev/J5/dt0nfLcNckLt0ZJjIo0 p6GXKRmW/cdaQBxTnFNF0D9x8E354nTWoTujWF4DV5yXOY3i+ws7BT13p6zTuMct6X ZXAmg1o/F0ZqZ/4/Mdq8tOUJgAI2BpxlRj3HUync= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lv Yunlong , Miquel Raynal , Sasha Levin Subject: [PATCH 5.10 207/530] mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init Date: Wed, 12 May 2021 16:45:17 +0200 Message-Id: <20210512144826.644866474@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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: Lv Yunlong [ Upstream commit 076de75de1e53160e9b099f75872c1f9adf41a0b ] If the callee gpmi_alloc_dma_buffer() failed to alloc memory for this->raw_buffer, gpmi_free_dma_buffer() will be called to free this->auxiliary_virt. But this->auxiliary_virt is still a non-NULL and valid ptr. Then gpmi_alloc_dma_buffer() returns err and gpmi_free_dma_buffer() is called again to free this->auxiliary_virt in err_out. This causes a double free. As gpmi_free_dma_buffer() has already called in gpmi_alloc_dma_buffer's error path, so it should return err directly instead of releasing the dma buffer again. Fixes: 4d02423e9afe6 ("mtd: nand: gpmi: Fix gpmi_nand_init() error path") Signed-off-by: Lv Yunlong Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20210403060905.5251-1-lyl2019@mail.ustc.edu.cn Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c index 31a6210eb5d4..a6658567d55c 100644 --- a/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c @@ -2447,7 +2447,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) this->bch_geometry.auxiliary_size = 128; ret = gpmi_alloc_dma_buffer(this); if (ret) - goto err_out; + return ret; nand_controller_init(&this->base); this->base.ops = &gpmi_nand_controller_ops; -- 2.30.2