mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 04:38:03 +00:00
ubi: eba: properly rollback inside self_check_eba
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: 00abf30415
("UBI: Add self_check_eba()")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
22a40d14b5
commit
745d9f4a31
@ -1564,6 +1564,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;
|
||||
}
|
||||
|
||||
@ -1599,7 +1600,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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user