From patchwork Mon Nov 23 08:29:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 7677991 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9BC6CBF90C for ; Mon, 23 Nov 2015 08:30:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C838C20630 for ; Mon, 23 Nov 2015 08:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA4432061D for ; Mon, 23 Nov 2015 08:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753893AbbKWI3o (ORCPT ); Mon, 23 Nov 2015 03:29:44 -0500 Received: from mail-pa0-f67.google.com ([209.85.220.67]:35928 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753499AbbKWI3l (ORCPT ); Mon, 23 Nov 2015 03:29:41 -0500 Received: by pabfh17 with SMTP id fh17so26164465pab.3; Mon, 23 Nov 2015 00:29:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=hFG/+xHxh9Fp/3BfEl19JwcUcJedmEWm2ybNDeELuiQ=; b=P5SUBOh1WGw9tdFf5i0fJVKaHKFYwObrJGjm1TxVx/pSDnWw47At6YYJTLRfzvazDD YdirmlF5gct462GiNWOqBvaF9Ym2HDuEL3EGblleWAheQe1gtLmSFhIP46fec1v/mIXq 19r/G2m5X5euKszG8Mcbeeej8WeL1sov1Qte+fmD2lZYTnnFRlbNw2oKjJfgCZL/YRO9 t/MKtTZZknKX7ZDQjluu7d3Ycw8vy/1aPAT3D7kjPIjRDBoJBpxtjEMKMZfZjkQpuOWG 6Z2BFVZ4/dtp7x4NNUtsQmviy1uctzBxWoJAKybjWAtdRxzEwOIXKT7a2WOruDMwgEk5 +y3w== X-Received: by 10.66.146.130 with SMTP id tc2mr33718552pab.26.1448267381192; Mon, 23 Nov 2015 00:29:41 -0800 (PST) Received: from localhost.localdomain.com ([111.204.49.2]) by smtp.gmail.com with ESMTPSA id q129sm8905243pfq.19.2015.11.23.00.29.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2015 00:29:40 -0800 (PST) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] lightnvm: free allocated memory when gennvm register fails Date: Mon, 23 Nov 2015 16:29:35 +0800 Message-Id: <1448267375-19009-1-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP free allocated nvm block and gennvm lun structures when gennvm register fails, otherwise it will cause memory leak. Signed-off-by: Wenwei Tao --- drivers/lightnvm/gennvm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index ae1fb2b..03fc7a5 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -211,12 +211,15 @@ static int gennvm_register(struct nvm_dev *dev) ret = gennvm_blocks_init(dev, gn); if (ret) { pr_err("gennvm: could not initialize blocks\n"); + gennvm_blocks_free(dev); + gennvm_luns_free(dev); goto err; } return 1; err: kfree(gn); + dev->mp = NULL; return ret; }