Re: [PATCH v2 15/15] libmultipath: avoid memory leak with uid_attrs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Apr 04, 2022 at 07:04:57PM +0200, mwilck@xxxxxxxx wrote:
> Free all vector elements when freeing uid_attrs.
> 
> Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>

Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>

> ---
>  libmultipath/config.c | 5 +++++
>  libmultipath/dict.c   | 5 +++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/libmultipath/config.c b/libmultipath/config.c
> index 7346c37..bfaf041 100644
> --- a/libmultipath/config.c
> +++ b/libmultipath/config.c
> @@ -656,6 +656,9 @@ static struct config *alloc_config (void)
>  
>  static void _uninit_config(struct config *conf)
>  {
> +	void *ptr;
> +	int i;
> +
>  	if (!conf)
>  		conf = &__internal_config;
>  
> @@ -668,6 +671,8 @@ static void _uninit_config(struct config *conf)
>  	if (conf->uid_attribute)
>  		free(conf->uid_attribute);
>  
> +	vector_foreach_slot(&conf->uid_attrs, ptr, i)
> +		free(ptr);
>  	vector_reset(&conf->uid_attrs);
>  
>  	if (conf->getuid)
> diff --git a/libmultipath/dict.c b/libmultipath/dict.c
> index 26cbe78..3b99296 100644
> --- a/libmultipath/dict.c
> +++ b/libmultipath/dict.c
> @@ -597,8 +597,13 @@ static int uid_attrs_handler(struct config *conf, vector strvec,
>  			     const char *file, int line_nr)
>  {
>  	char *val;
> +	void *ptr;
> +	int i;
>  
> +	vector_foreach_slot(&conf->uid_attrs, ptr, i)
> +		free(ptr);
>  	vector_reset(&conf->uid_attrs);
> +
>  	val = set_value(strvec);
>  	if (!val)
>  		return 1;
> -- 
> 2.35.1
--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux