mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-23 13:56:20 +00:00
cmd: ubi: check 'updating' before calling ubi_more_update_data()
If 0 is passed to the 'bytes' parameter in the ubi_start_update(), there is no need to call the ubi_more_update_data(). Otherwise, there will be a double-free of 'vol->upd_buf'. Also check that the ubi_start_update() was called before calling the ubi_more_update_data(). Signed-off-by: Martin Kurbanov <mmkurbanov@salutedevices.com>
This commit is contained in:
parent
abae0b76f9
commit
27b169f9d0
1 changed files with 9 additions and 0 deletions
|
@ -362,6 +362,11 @@ static int ubi_volume_continue_write(char *volume, void *buf, size_t size)
|
||||||
if (vol == NULL)
|
if (vol == NULL)
|
||||||
return ENODEV;
|
return ENODEV;
|
||||||
|
|
||||||
|
if (!vol->updating) {
|
||||||
|
printf("UBI volume update was not initiated\n");
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
err = ubi_more_update_data(ubi, vol, buf, size);
|
err = ubi_more_update_data(ubi, vol, buf, size);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
printf("Couldnt or partially wrote data\n");
|
printf("Couldnt or partially wrote data\n");
|
||||||
|
@ -411,6 +416,10 @@ int ubi_volume_begin_write(char *volume, void *buf, size_t size,
|
||||||
return -err;
|
return -err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The volume is just wiped out */
|
||||||
|
if (!full_size)
|
||||||
|
return 0;
|
||||||
|
|
||||||
return ubi_volume_continue_write(volume, buf, size);
|
return ubi_volume_continue_write(volume, buf, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue