mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-02-06 11:19:56 +00:00
UBI: fix leak in ubi_scan_erase_peb
Coverity (1769) found the following problem: if the erase counter overflow check triggers, ec_hdr is leaked. Moving the allocation after the overflow check should take care of it. Signed-off-by: Florin Malita <fmalita@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
bbf25010f1
commit
dcec4c3bdc
@ -673,10 +673,6 @@ int ubi_scan_erase_peb(const struct ubi_device *ubi,
|
|||||||
int err;
|
int err;
|
||||||
struct ubi_ec_hdr *ec_hdr;
|
struct ubi_ec_hdr *ec_hdr;
|
||||||
|
|
||||||
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
|
|
||||||
if (!ec_hdr)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if ((long long)ec >= UBI_MAX_ERASECOUNTER) {
|
if ((long long)ec >= UBI_MAX_ERASECOUNTER) {
|
||||||
/*
|
/*
|
||||||
* Erase counter overflow. Upgrade UBI and use 64-bit
|
* Erase counter overflow. Upgrade UBI and use 64-bit
|
||||||
@ -686,6 +682,10 @@ int ubi_scan_erase_peb(const struct ubi_device *ubi,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
|
||||||
|
if (!ec_hdr)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
ec_hdr->ec = cpu_to_be64(ec);
|
ec_hdr->ec = cpu_to_be64(ec);
|
||||||
|
|
||||||
err = ubi_io_sync_erase(ubi, pnum, 0);
|
err = ubi_io_sync_erase(ubi, pnum, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user