module: Move local_err initialization to the loop in module_load_qom_all()
v2 cover module: Move local_err initialization to the loop in module_load_qom_all()
After updating QEMU modules previously executed QEMU processes crash on module loading. It happens because error_setg() calls with a not NULL errp argument.
There is a discussion - https://issues.redhat.com/browse/RHEL-29848
Note: The commit subject was changed. Previously it was called "module:
Prevent crash by resetting local_err in module_load_qom_all()"
v2: Move local_err initialization inside the loop.
Alexander Ivanov (1):
module: Move local_err initialization to the loop in
module_load_qom_all()
util/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.43.0
PATCH v2 1/1 module: Move local_err initialization to the loop in module_load_qom_all()
Move local_err initialization inside the loop in the module_load_qom_all() function. This change ensures that the error variable is reset to NULL for each iteration of the loop. This prevents triggering assert(*errp == NULL) failure in error_setv() when local_err is reused in the loop.
Note: The local_err variable is freed in error_report_err() so there is no any leak.
--- util/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/module.c +1 -1
@@ -354,13 +354,13 @@ int module_load_qom(const char *type, Error **errp)void module_load_qom_all (void ) {const QemuModinfo *modinfo; -Error *local_err =NULL ;if (module_loaded_qom_all) {return ; }for (modinfo = module_info; modinfo->name !=NULL ; modinfo++) { +Error *local_err =NULL ;if (!modinfo->objs) {continue ; }
Signature · 1 line
2.43.0
Quoted 5 lines · Alexander Ivanov
Move
local_errinitialization inside the loop in themodule_load_qom_all()function. This change ensures that the error variable is reset to NULL for each iteration of the loop. This prevents triggeringassert(*errp == NULL)failure inerror_setv()whenlocal_erris reused in the loop.
Quoted 7 lines
Note: The
local_errvariable is freed inerror_report_err()so there is no any leak.Signed-off-by Alexander Ivanov<[email protected]>--- util/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 32 lines · Alexander Ivanov
Move
local_errinitialization inside the loop in themodule_load_qom_all()function. This change ensures that the error variable is reset to NULL for each iteration of the loop. This prevents triggeringassert(*errp == NULL)failure inerror_setv()whenlocal_erris reused in the loop.Note: The
local_errvariable is freed inerror_report_err()so there is no any leak.Signed-off-by Alexander Ivanov <[email protected]>--- util/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)util/module.c +1
-1@@ -354,13 +354,13 @@ int module_load_qom(const char *type, Error **errp)void module_load_qom_all (void ) {const QemuModinfo *modinfo; -Error *local_err =NULL ;if (module_loaded_qom_all) {return ; }for (modinfo = module_info; modinfo->name !=NULL ; modinfo++) { +Error *local_err =NULL ;if (!modinfo->objs) {continue ; }
Quoted 9 lines · Alexander Ivanov
Move
local_errinitialization inside the loop in themodule_load_qom_all()function. This change ensures that the error variable is reset to NULL for each iteration of the loop. This prevents triggeringassert(*errp == NULL)failure inerror_setv()whenlocal_erris reused in the loop.Note: The
local_errvariable is freed inerror_report_err()so there is no any leak.Signed-off-by Alexander Ivanov <[email protected]>
This can be applied through the trivial tree (Cc'd).
Thanks,
/mjt
Signature · 4 lines
GPG Key transition (from rsa2048 to rsa4096) since 2024-04-24. New key: rsa4096/61AD3D98ECDF2C8E 9D8B E14E 3F2A 9DD7 9199 28F1 61AD 3D98 ECDF 2C8E Old key: rsa2048/457CE0A0804465C5 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5 Transition statement: http://www.corpit.ru/mjt/gpg-transition-2024.txt