]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ubifs: Fix wrong memory allocation
authorSascha Hauer <s.hauer@pengutronix.de>
Wed, 4 Dec 2019 10:09:58 +0000 (11:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:36:51 +0000 (04:36 -0800)
commit edec51374bce779f37fc209a228139c55d90ec8d upstream.

In create_default_filesystem() when we allocate the idx node we must use
the idx_node_size we calculated just one line before, not tmp, which
contains completely other data.

Fixes: c4de6d7e4319 ("ubifs: Refactor create_default_filesystem()")
Cc: stable@vger.kernel.org # v4.20+
Reported-by: Naga Sureshkumar Relli <nagasure@xilinx.com>
Tested-by: Naga Sureshkumar Relli <nagasure@xilinx.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ubifs/sb.c

index 2b7c04bf8983e3fb9dca811058fc583ad3bd7b25..17c90dff7266f555a32f24e548638bb158613565 100644 (file)
@@ -161,7 +161,7 @@ static int create_default_filesystem(struct ubifs_info *c)
        sup = kzalloc(ALIGN(UBIFS_SB_NODE_SZ, c->min_io_size), GFP_KERNEL);
        mst = kzalloc(c->mst_node_alsz, GFP_KERNEL);
        idx_node_size = ubifs_idx_node_sz(c, 1);
-       idx = kzalloc(ALIGN(tmp, c->min_io_size), GFP_KERNEL);
+       idx = kzalloc(ALIGN(idx_node_size, c->min_io_size), GFP_KERNEL);
        ino = kzalloc(ALIGN(UBIFS_INO_NODE_SZ, c->min_io_size), GFP_KERNEL);
        cs = kzalloc(ALIGN(UBIFS_CS_NODE_SZ, c->min_io_size), GFP_KERNEL);