Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29f2c831 authored by Fedor Pchelkin's avatar Fedor Pchelkin Committed by Greg Kroah-Hartman
Browse files

ubi: eba: properly rollback inside self_check_eba



commit 745d9f4a31defec731119ee8aad8ba9f2536dd9a upstream.

In case of a memory allocation failure in the volumes loop we can only
process the already allocated scan_eba and fm_eba array elements on the
error path - others are still uninitialized.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 00abf304 ("UBI: Add self_check_eba()")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2f35342e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1573,6 +1573,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
					  GFP_KERNEL);
		if (!fm_eba[i]) {
			ret = -ENOMEM;
			kfree(scan_eba[i]);
			goto out_free;
		}

@@ -1608,7 +1609,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
	}

out_free:
	for (i = 0; i < num_volumes; i++) {
	while (--i >= 0) {
		if (!ubi->volumes[i])
			continue;