From patchwork Tue May 16 23:58:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyeoncheol Lee X-Patchwork-Id: 9729815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D127D60386 for ; Wed, 17 May 2017 00:00:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2C3028741 for ; Wed, 17 May 2017 00:00:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4A4728922; Wed, 17 May 2017 00:00:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3583228741 for ; Wed, 17 May 2017 00:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752835AbdEQAAn (ORCPT ); Tue, 16 May 2017 20:00:43 -0400 Received: from LGEAMRELO12.lge.com ([156.147.23.52]:51309 "EHLO lgeamrelo12.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751203AbdEQAAm (ORCPT ); Tue, 16 May 2017 20:00:42 -0400 Received: from unknown (HELO lgeamrelo04.lge.com) (156.147.1.127) by 156.147.23.52 with ESMTP; 17 May 2017 09:00:39 +0900 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: cheol.lee@lge.com Received: from unknown (HELO LGEAEXHB03P.LGE.NET) (165.244.249.23) by 156.147.1.127 with ESMTP; 17 May 2017 08:58:05 +0900 X-Original-SENDERIP: 165.244.249.23 X-Original-MAILFROM: cheol.lee@lge.com Received: from lgekrmhub04.lge.com (10.185.110.14) by LGEAEXHB03P.LGE.NET (165.244.249.23) with Microsoft SMTP Server id 8.3.264.0; Wed, 17 May 2017 08:58:04 +0900 Received: from lgeamrelo01.lge.com ([156.147.1.125]) by lgekrmhub04.lge.com (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017051708580389-2846988 ; Wed, 17 May 2017 08:58:03 +0900 Received: from unknown (HELO localhost.localdomain) (10.177.225.40) by 156.147.1.125 with ESMTP; 17 May 2017 08:58:04 +0900 X-Original-SENDERIP: 10.177.225.40 X-Original-MAILFROM: cheol.lee@lge.com From: Hyunchul Lee To: Richard Weinberger CC: Artem Bityutskiy , , , , , Subject: [PATCH 2/2] ubifs: Fix memory leak in RENAME_WHITEOUT error path in do_rename Date: Wed, 17 May 2017 08:58:02 +0900 Message-ID: <1494979082-19414-1-git-send-email-cheol.lee@lge.com> X-Mailer: git-send-email 1.9.1 X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/05/17 08:58:04, Serialize by Router on LGEKRMHUB04/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/05/17 08:58:04, Serialize complete at 2017/05/17 08:58:04 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP in RENAME_WHITEOUT error path, fscrypt_name should be freed. Signed-off-by: Hyunchul Lee --- fs/ubifs/dir.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index df67236..0d5f8e7 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1385,17 +1385,14 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, dev = kmalloc(sizeof(union ubifs_dev_desc), GFP_NOFS); if (!dev) { - ubifs_release_budget(c, &req); - ubifs_release_budget(c, &ino_req); - return -ENOMEM; + err = -ENOMEM; + goto out_release; } err = do_tmpfile(old_dir, old_dentry, S_IFCHR | WHITEOUT_MODE, &whiteout); if (err) { - ubifs_release_budget(c, &req); - ubifs_release_budget(c, &ino_req); kfree(dev); - return err; + goto out_release; } whiteout->i_state |= I_LINKABLE; @@ -1483,12 +1480,10 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, err = ubifs_budget_space(c, &wht_req); if (err) { - ubifs_release_budget(c, &req); - ubifs_release_budget(c, &ino_req); kfree(whiteout_ui->data); whiteout_ui->data_len = 0; iput(whiteout); - return err; + goto out_release; } inc_nlink(whiteout); @@ -1543,6 +1538,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, iput(whiteout); } unlock_4_inodes(old_dir, new_dir, new_inode, whiteout); +out_release: ubifs_release_budget(c, &ino_req); ubifs_release_budget(c, &req); fscrypt_free_filename(&old_nm);