diff mbox series

[i-g-t,1/4] tests/core_hotunplug: Free mem allocated by igt_audio_driver_unload

Message ID 20220913120441.146757-2-janusz.krzysztofik@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series tests/core_hotunplug: A couple of fixes and enhancements | expand

Commit Message

Janusz Krzysztofik Sept. 13, 2022, 12:04 p.m. UTC
Since we pass NULL to igt_audio_driver_unload(), realloc() it calls
allocates new memory for us.  Free it each time we no longer need it,
before dropping a pointer to it, to avoid memory leaking.

Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
---
 tests/core_hotunplug.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Mauro Carvalho Chehab Sept. 20, 2022, 5:04 a.m. UTC | #1
On Tue, 13 Sep 2022 14:04:38 +0200
Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com> wrote:

> Since we pass NULL to igt_audio_driver_unload(), realloc() it calls
> allocates new memory for us.  Free it each time we no longer need it,
> before dropping a pointer to it, to avoid memory leaking.
> 
> Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>

Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>

> ---
>  tests/core_hotunplug.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
> index a0d29b799a..733ea8efb0 100644
> --- a/tests/core_hotunplug.c
> +++ b/tests/core_hotunplug.c
> @@ -187,6 +187,7 @@ static void driver_bind(struct hotunplug *priv, int timeout)
>  	if (priv->snd_driver) {
>  		igt_info("Realoading %s\n", priv->snd_driver);
>  		igt_kmod_load(priv->snd_driver, NULL);
> +		free(priv->snd_driver);
>  		priv->snd_driver = NULL;
>  	}
>  }
diff mbox series

Patch

diff --git a/tests/core_hotunplug.c b/tests/core_hotunplug.c
index a0d29b799a..733ea8efb0 100644
--- a/tests/core_hotunplug.c
+++ b/tests/core_hotunplug.c
@@ -187,6 +187,7 @@  static void driver_bind(struct hotunplug *priv, int timeout)
 	if (priv->snd_driver) {
 		igt_info("Realoading %s\n", priv->snd_driver);
 		igt_kmod_load(priv->snd_driver, NULL);
+		free(priv->snd_driver);
 		priv->snd_driver = NULL;
 	}
 }