hw/core: Fix fit_load_fdt() error API violations
fit_load_fdt() passes @errp to fit_image_addr(), then recovers from ENOENT failures. Passing @errp is wrong, because it works only as long as @errp is neither @error_fatal nor @error_abort. Error recovery dereferences @errp. That's also wrong; see the big comment in error.h. Error recovery can leave *errp pointing to a freed Error object. Wrong, it must be null on success. Messed up in commit 3eb99edb48 "loader-fit: Wean off error_printf()". No caller actually passes such values, or uses *errp on success. Fix anyway: splice in a local Error *err, and error_propagate(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191204093625.14836-8-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
This commit is contained in:
parent
49e3e11f8f
commit
bc0e339b01
@ -178,11 +178,12 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
|
||||
int cfg, void *opaque, const void *match_data,
|
||||
hwaddr kernel_end, Error **errp)
|
||||
{
|
||||
Error *err = NULL;
|
||||
const char *name;
|
||||
const void *data;
|
||||
const void *load_data;
|
||||
hwaddr load_addr;
|
||||
int img_off, err;
|
||||
int img_off;
|
||||
size_t sz;
|
||||
int ret;
|
||||
|
||||
@ -197,13 +198,13 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = fit_image_addr(itb, img_off, "load", &load_addr, errp);
|
||||
if (err == -ENOENT) {
|
||||
ret = fit_image_addr(itb, img_off, "load", &load_addr, &err);
|
||||
if (ret == -ENOENT) {
|
||||
load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB);
|
||||
error_free(*errp);
|
||||
} else if (err) {
|
||||
error_prepend(errp, "unable to read FDT load address from FIT: ");
|
||||
ret = err;
|
||||
error_free(err);
|
||||
} else if (ret) {
|
||||
error_propagate_prepend(errp, err,
|
||||
"unable to read FDT load address from FIT: ");
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user