Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3699288ybv; Mon, 10 Feb 2020 04:57:14 -0800 (PST) X-Google-Smtp-Source: APXvYqwQ58E9o25VPQHgbtliUt0sCDPyagCXyPDbL1vkGDbgaok7/GB9QsipW3kjrPhQ+eFZzEQq X-Received: by 2002:a9d:7304:: with SMTP id e4mr868885otk.99.1581339433969; Mon, 10 Feb 2020 04:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339433; cv=none; d=google.com; s=arc-20160816; b=xx0egKQ6VBwuI6ugS9n9lCjy67lHd9MqJfB2IF8+c1YGkBMSw6nux3GMJ5/TPSXQtr tUIfAIwZTvzXA2uU9pZSAcouV2EwO/UMBhKABaPdJp17GQT8ogAsAiowDL2vyFJgR508 rIItHSyLIPjrpNuCTsWdrnp3/1HQ/mShK+2TTlnX2vpdHvXbVPcKGn9cKY44wtZ3xHkn WwqoIpmfhyYtbE9tw1q3ul15VdQ9oJr/bs5aEhrJ9hoHT9nDo290Q7pajvChqKXR2/Vx vO7L+WMAuyh3JG5AmLUv0U0NkM/kAG3VKn/1XzxNrngTRci+1u+vyblICpB/6lNSAf7L eHJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cw7rtG4YV3pL64YfDMaP5gzQy16ks2IpaLr2WKVCg98=; b=x7Ed3zU6qaWfjTDBwOpC0KcEb5iGGrI8aMGC1s6cY4hPqXcHIK+u9ntACznEbXD+gT ZdZ8S3eKhhehLwNJeLbFVRQG45yPoX8M6ix2uSYogsFtuzr1s7lndWLLv5tZr+z49LEz USmJug9V+VkWHi797F8t6fA7BHNZUCvFQRLIHR6dXBUunEy5s0wzxI5RuYBjYIzQf2UJ jYhe1z6/YCH5hzIT0O+v9VMkQspc5MnVU+5P2rFnqaNTr49r+xOMeXp0nBCcG8R6jvUf czImO+gd2EjadDI1ScNc5LJx5JXzIBKITQtXMlzvi2yieB3Atv6tyTa33Oi8vfj9XiVu kr+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=inyQMbRE; 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 d22si137969oti.316.2020.02.10.04.57.01; Mon, 10 Feb 2020 04:57:13 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=inyQMbRE; 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 S1729657AbgBJMzu (ORCPT + 99 others); Mon, 10 Feb 2020 07:55:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:44700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730062AbgBJMlq (ORCPT ); Mon, 10 Feb 2020 07:41:46 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2998B20838; Mon, 10 Feb 2020 12:41:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338505; bh=mzdjs+2HjVphOcK4CSN3hLYnd9zBpyrzM4m11ddEtJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=inyQMbRE21tNiKSc8eOjm8RTmE4Rlp0kpHyiwx5h1mD+fG9P2HgCM6DI/ytqGFD84 Vc+g5ETCY7v5l3ltOGeZZm5tD18G6NoV7Dj+33QAJNTCnT/PhA2pAfEQdU7IA7s0/9 xDyktQuAO8ueGjpsaOfYitMK3KXVOX82U3sHxfwY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Quanyang Wang , Richard Weinberger Subject: [PATCH 5.5 305/367] ubifs: Fix memory leak from c->sup_node Date: Mon, 10 Feb 2020 04:33:38 -0800 Message-Id: <20200210122451.609554684@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Quanyang Wang commit ff90bdfb206e49c8b418811efbdd0c77380fa8c2 upstream. The c->sup_node is allocated in function ubifs_read_sb_node but is not freed. This will cause memory leak as below: unreferenced object 0xbc9ce000 (size 4096): comm "mount", pid 500, jiffies 4294952946 (age 315.820s) hex dump (first 32 bytes): 31 18 10 06 06 7b f1 11 02 00 00 00 00 00 00 00 1....{.......... 00 10 00 00 06 00 00 00 00 00 00 00 08 00 00 00 ................ backtrace: [] ubifs_read_superblock+0x48/0xebc [] ubifs_mount+0x974/0x1420 [<8589ecc3>] legacy_get_tree+0x2c/0x50 [<5f1fb889>] vfs_get_tree+0x28/0xfc [] do_mount+0x4f8/0x748 [<4151f538>] ksys_mount+0x78/0xa0 [] ret_fast_syscall+0x0/0x54 [<1cc40005>] 0x7ea02790 Free it in ubifs_umount and in the error path of mount_ubifs. Fixes: fd6150051bec ("ubifs: Store read superblock node") Signed-off-by: Quanyang Wang Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- fs/ubifs/super.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1599,6 +1599,7 @@ out_free: vfree(c->ileb_buf); vfree(c->sbuf); kfree(c->bottom_up_buf); + kfree(c->sup_node); ubifs_debugging_exit(c); return err; } @@ -1641,6 +1642,7 @@ static void ubifs_umount(struct ubifs_in vfree(c->ileb_buf); vfree(c->sbuf); kfree(c->bottom_up_buf); + kfree(c->sup_node); ubifs_debugging_exit(c); }