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

Commit 87ed89d2 authored by Tanya Brokhman's avatar Tanya Brokhman Committed by Artem Bityutskiy
Browse files

UBI: fix error path in __wl_get_peb



In case of an error (if there are not free PEB's for example),
__wl_get_peb will return a negative value. In order to prevent access
violation we need to test the returned value prior to using it later on.

Signed-off-by: default avatarTatyana Brokhman <tlinder@codeaurora.org>
Reviewed-by: default avatarDolev Raviv <draviv@codeaurora.org>
Acked-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
parent fcdd57c8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -684,6 +684,9 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
	peb = __wl_get_peb(ubi);
	spin_unlock(&ubi->wl_lock);

	if (peb < 0)
		return peb;

	err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
				    ubi->peb_size - ubi->vid_hdr_aloffset);
	if (err) {