Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3558546ybl; Mon, 19 Aug 2019 21:45:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjDTNGfH9Lqm6SFMQtU+tUSETMMQ9xqM02kymOI8l4ZwGJkRPN4P8UgNiuQwKnBInUlX4y X-Received: by 2002:a63:dc4f:: with SMTP id f15mr23317330pgj.227.1566276335222; Mon, 19 Aug 2019 21:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566276335; cv=none; d=google.com; s=arc-20160816; b=0hMstgl9SWL2FGsW2PMUFzsTsQJcNXvv+DAfxHqhB7ol1deUq5XsOAflwuCN12EA4G wdDLFeMenmiLk8EHFcaU4KyiBOcopfBOJF20PCrHD21lCQBLE8qFf5yulstlTb79BIY0 YMDnA4gqx8KjGMTNLwxKQAArHaGG712N0vxYlgYoxjVVl7qE2pmbFW1IQU9GSMuJ3s3h PqLtpoKY7m6oOW7eFcMHzNnswInE1biSs02aJKwsiKSrMi/C+v5XIJkaf7Kf/6qeAgwT nUugGxHMsjo3Gjv8GuzzORteEugY1aYJYIA00zSDgfmvOfNuZkkFONWISf0B8asU7miM QSQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=r71QpmjjYMneD14So1/FrWnFg6w/jYQUum7iTbCpFnc=; b=cN3l7hExSbt4q5tjSl0TQyoIHC81tp9WYAtdTpa4SWCA9lV6WJdcP4n6Y930P03hB9 B1nLifb0m9pQuzH/mUlICS9dSG+ZECBCycHn35Xgadon3w17NA8iAnwrLlP+IahKb5Ix m7c03kbGc9+OLlQR/DZruFyiRycXnbWXrKuI6tbHaGPQvLxRakUNxdh9JGIAF8KMUfIW 3AWtTkpVtajAzGTDUAuBIqpQssmYi6cLgVhNpORn1mKXKeRRg+8gEczlNLZ0x9Mm9KHh JwyLQO9p1p29AexSiOy9U5fwL5aMG1+9LCdJE7JjLgWBD/VyEsrb31Y6L1XYgC5rqmYU GR3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si10282319pjb.73.2019.08.19.21.45.19; Mon, 19 Aug 2019 21:45:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729002AbfHTEob (ORCPT + 99 others); Tue, 20 Aug 2019 00:44:31 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:42485 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726667AbfHTEob (ORCPT ); Tue, 20 Aug 2019 00:44:31 -0400 Received: by mail-yw1-f65.google.com with SMTP id z63so1888561ywz.9 for ; Mon, 19 Aug 2019 21:44:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=r71QpmjjYMneD14So1/FrWnFg6w/jYQUum7iTbCpFnc=; b=pmbBIdgBvXJh/LzamzcRicVnUnb/80ciU8vkeg542Gd6MgsONkNBv0zXMB/j89sW9K sgahVACGovfX+nOfyFtnZTJ7Yyb7e6RyJSB4STbtBLu1gLjksiipxCa+k3vsO9DWC5Ft Dt920FKfYUK7nkXWiPHFEqclXCEM79tlGRLf0+RzPjeTnoR73ctG+RfX6FJzIl2Fia5c W/7uQjZE6YsqL5d023Fy/jLZczbsn0GZIC2pNI9Ha8E4TKNLf2H6ZR75pytwKCzXwFEA 9ZuM8cl+JzA/+wg02OhQeQzyylrAeQbn6rCECchlTCi5CyEtnfLYR/0inizThIMJ82R3 oe6A== X-Gm-Message-State: APjAAAXnQZIQtvPPujHhBxyCX9/LzWVb09gub677kOuiou1C1mdyPjVk xy84IAaNpnEd/BM7tfoLFvU= X-Received: by 2002:a0d:d557:: with SMTP id x84mr17497695ywd.455.1566276270669; Mon, 19 Aug 2019 21:44:30 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id z9sm3501119ywj.84.2019.08.19.21.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Aug 2019 21:44:29 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Richard Weinberger , Artem Bityutskiy , Adrian Hunter , linux-mtd@lists.infradead.org (open list:UBI FILE SYSTEM (UBIFS)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] ubifs: fix a memory leak bug Date: Mon, 19 Aug 2019 23:44:24 -0500 Message-Id: <1566276264-8942-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ubifs_mount(), 'c' is allocated through kzalloc() in alloc_ubifs_info(). However, it is not deallocated in the following execution if ubifs_fill_super() fails, leading to a memory leak bug. To fix this issue, free 'c' before going to the 'out_deact' label. Signed-off-by: Wenwen Wang --- fs/ubifs/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 2c0803b..46e30e2 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2252,8 +2252,10 @@ static struct dentry *ubifs_mount(struct file_system_type *fs_type, int flags, } } else { err = ubifs_fill_super(sb, data, flags & SB_SILENT ? 1 : 0); - if (err) + if (err) { + kfree(c); goto out_deact; + } /* We do not support atime */ sb->s_flags |= SB_ACTIVE; if (IS_ENABLED(CONFIG_UBIFS_ATIME_SUPPORT)) -- 2.7.4