diff mbox series

[v2,1/1] module: Move local_err initialization to the loop in module_load_qom_all()

Message ID 20240812085725.1093540-2-alexander.ivanov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series module: Move local_err initialization to the loop in module_load_qom_all() | expand

Commit Message

Alexander Ivanov Aug. 12, 2024, 8:57 a.m. UTC
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.

Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
 util/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Henderson Aug. 12, 2024, 9:09 a.m. UTC | #1
On 8/12/24 18:57, Alexander Ivanov wrote:
> 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.
> 
> Signed-off-by: Alexander Ivanov<alexander.ivanov@virtuozzo.com>
> ---
>   util/module.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Claudio Fontana Aug. 12, 2024, 3:51 p.m. UTC | #2
Reviewed-by: Claudio Fontana <cfontana@suse.de>

On 8/12/24 10:57, Alexander Ivanov wrote:
> 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.
> 
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
> ---
>  util/module.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/util/module.c b/util/module.c
> index 32e263163c..3eb0f06df1 100644
> --- a/util/module.c
> +++ b/util/module.c
> @@ -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;
>          }
diff mbox series

Patch

diff --git a/util/module.c b/util/module.c
index 32e263163c..3eb0f06df1 100644
--- a/util/module.c
+++ b/util/module.c
@@ -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;
         }