[email protected] writes: >> When erasing a keyslot we deliberately ignore some errors and >> carry on trying to erase as much as possible. This results in >> overwriting Error objects and triggering an assertion. Don't >> pass in the &local_err, if errp is already set. >> >> Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/4697 >> Signed-off-by: Daniel P. Berrangé <[email protected]> >> Message-ID: <[email protected]> >> --- >> crypto/block-luks.c | 17 +++++++++++++---- >> 1 file changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/crypto/block-luks.c b/crypto/block-luks.c >> index 0926ad28f0cd..8a1df846a146 100644 >> --- a/crypto/block-luks.c >> +++ b/crypto/block-luks.c >> @@ -1152,22 +1152,29 @@ qcrypto_block_luks_erase_key(QCryptoBlock *block, >> >> if (ret < 0) { >> error_propagate(errp, local_err); >> + local_err = NULL; >> } >> + >> /* >> * Now try to erase the key material, even if the header >> * update failed >> */ >> for (i = 0; i < QCRYPTO_BLOCK_LUKS_ERASE_ITERATIONS; i++) { >> if (qcrypto_random_bytes(garbagesplitkey, >> - splitkeylen, &local_err) < 0) { >> + splitkeylen, >> + errp && *errp ? NULL : &local_err) < 0) { > > I think the current code was simpler. error_propagate() will simpliy discard > local_err if errp is already set. It is just missing "local_err = NULL;"
Moreover, *errp is wrong without ERRP_GUARD(). [...]
