]> git.itanic.dy.fi Git - linux-stable/commit
ubi: Fix an error pointer dereference in error handling code
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 13 Jan 2020 13:23:46 +0000 (16:23 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:34:14 +0000 (04:34 -0800)
commitd9e9451c8ff79fd92b0b83f935a1450503529bd1
tree20c12d0fb3eaf9cdc39283fe0de977908fa7220a
parent5fe3a95d2b094c778db751528f78f362287fa378
ubi: Fix an error pointer dereference in error handling code

commit 5d3805af279c93ef49a64701f35254676d709622 upstream.

If "seen_pebs = init_seen(ubi);" fails then "seen_pebs" is an error pointer
and we try to kfree() it which results in an Oops.

This patch re-arranges the error handling so now it only frees things
which have been allocated successfully.

Fixes: daef3dd1f0ae ("UBI: Fastmap: Add self check to detect absent PEBs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mtd/ubi/fastmap.c