Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756468AbcDDU6o (ORCPT ); Mon, 4 Apr 2016 16:58:44 -0400 Received: from mail-am1on0071.outbound.protection.outlook.com ([157.56.112.71]:18141 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752534AbcDDU6n (ORCPT ); Mon, 4 Apr 2016 16:58:43 -0400 Authentication-Results: nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; From: Han Xu To: , , , , CC: , Subject: [PATCH] mtd: gpmi: fix raw_buffer pointer double free issue Date: Mon, 4 Apr 2016 15:41:29 -0500 Message-ID: <1459802489-30382-1-git-send-email-han.xu@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: BY2PR06CA048.namprd06.prod.outlook.com (10.141.250.166) To DB5PR0401MB1799.eurprd04.prod.outlook.com (10.165.5.153) X-MS-Office365-Filtering-Correlation-Id: 8e7a5a9f-627b-4d5c-0f2a-08d35ccbe632 X-Microsoft-Exchange-Diagnostics: 1;DB5PR0401MB1799;2:YUmjfAEJxCFrBdfgduabnBCW2VXjygCzW6wulvQZtz20GlEsDXp/vSI6Qw/JlUxjg4Vehz3c4ie5QDX1oC3fpjIgfhH7ORcGv9GGUtTDP3K4ZWIGhUchw4RU0/gm8ZRRbGf9A3SelRIYfHkOxwF5XS2cCxy6QmXan5x9jO8OBlO5ynzuzw4VfuZK2/pC2/Rm;3:f5aCBCZZkw/FEiwrkNkrh77DIIZLFZPZFbYrKSyvJhnxmxNpNGoFnQRsZWUAfd1E0i9C3RH9Z0sgJjnm3+t4KdjPR+SIESGUbJtUqBm+9+d7DXAbKUEZoN/pJJR3iNRl;25:Wz6QybB1jWaJ2/tyBbAFL0tsYx2utWXX98w9Y8oDQ3T78KuFPmixV73XpE1diQNr8wAmcMncIvVmjm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0Q/qDpQ9xUaNT8mIlxBcSKFW4j25mjJxyi35ZuemdFbr3Vqm6KhhfeIzpl0iCe4Nrz/;4:1JYy5CU7/VTUh+VA6LZOKGjuwWESUqF+JXigKf22awvGER/xtBmx2iIXJds5C7AwXeQwIKdApqP6GQA2BiDHH3zzKHHnt3xmdDfQs3lm8lh0DBoF7E9LKIdUP/TqnmKC0/DV23QFsbt9L0T7Qdg5L0c9ooRZQ9avg4vrw3VGareOTArrP5CmbTGO5LyAo/fFlHVnPry7lbF11jVCi/rGs5qjFXC1430jfKQFukjNzh31Ixtu+iu2pArMbvZlhtwlVEPPA2isy3ya+uOC6rA+pFB8r8J5nc/t3ChK6IZrVmqBwyr13iN/ucFS3/De1h9H7JOPiXmvhKsMQQxXyohRO/hl/ljIq1u9spLfVjUOByb4UtEgQVFE5lSC3PeMvrfg X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:DB5PR0401MB1799;BCL:0;PCL:0;RULEID:;SRVR:DB5PR0401MB1799; X-Forefront-PRVS: 0902222726 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(50466002)(5008740100001)(5003940100001)(50986999)(36756003)(92566002)(66066001)(5004730100002)(229853001)(48376002)(42186005)(47776003)(2201001)(86362001)(33646002)(50226001)(77096005)(5001770100001)(4326007)(2906002)(19580395003)(189998001)(19580405001)(3846002)(6116002)(586003)(1096002)(81166005);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR0401MB1799;H:chopperman.am.freescale.net;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DB5PR0401MB1799;23:cLlB3OXG6IjN3HhXDOp6lznQ9bzVdyrWIyBOdvNrKku64rn2AiHiGybWxF+ugne4hw8pmSqzh7OmiaDMrI5JtfM+IRrNtUKS6VFxpgmn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agnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2016 20:58:38.2184 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR0401MB1799 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 850 Lines: 29 fix the raw_buffer pointer double free issue found by coverify. CID 18344 (#2 of 2): Double free (USE_AFTER_FREE) 3. double_free: Calling gpmi_alloc_dma_buffer frees pointer this->raw_buffer which has already been freed Signed-off-by: Han Xu --- changes in v2: - add coverity check log --- drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c index 8122c69..dcb60b0 100644 --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c @@ -797,6 +797,7 @@ static void gpmi_free_dma_buffer(struct gpmi_nand_data *this) this->cmd_buffer = NULL; this->data_buffer_dma = NULL; + this->raw_buffer = NULL; this->page_buffer_virt = NULL; this->page_buffer_size = 0; } -- 1.9.1