Re: [PATCH] libmpathpersist: fix resource leak in update_map_pr()

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

 



On Thu, Feb 02, 2023 at 09:42:20AM +0100, mwilck@xxxxxxxx wrote:
> From: Martin Wilck <mwilck@xxxxxxxx>
> 
> The "no available paths" case would leak the memory resp points to.
> Found by coverity.
> 
> Fixes: 50e2c16 ("multipathd: handle no active paths in update_map_pr")

Oops.
Reviewed-by: Benjamin Marzinski <bmarzins@xxxxxxxxxx>

> 
> Signed-off-by: Martin Wilck <mwilck@xxxxxxxx>
> ---
>  libmpathpersist/mpath_persist_int.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/libmpathpersist/mpath_persist_int.c b/libmpathpersist/mpath_persist_int.c
> index 8b52b74..178c2f5 100644
> --- a/libmpathpersist/mpath_persist_int.c
> +++ b/libmpathpersist/mpath_persist_int.c
> @@ -733,7 +733,7 @@ int update_map_pr(struct multipath *mpp)
>  	int noisy=0;
>  	struct prin_resp *resp;
>  	unsigned int i;
> -	int ret, isFound;
> +	int ret = MPATH_PR_OTHER, isFound;
>  
>  	if (!get_be64(mpp->reservation_key))
>  	{
> @@ -754,7 +754,7 @@ int update_map_pr(struct multipath *mpp)
>  	{
>  		condlog(0,"%s: No available paths to check pr status",
>  			mpp->alias);
> -		return MPATH_PR_OTHER;
> +		goto out;
>  	}
>  	mpp->prflag = PRFLAG_UNSET;
>  	ret = mpath_prin_activepath(mpp, MPATH_PRIN_RKEY_SA, resp, noisy);
> @@ -762,15 +762,15 @@ int update_map_pr(struct multipath *mpp)
>  	if (ret != MPATH_PR_SUCCESS )
>  	{
>  		condlog(0,"%s : pr in read keys service action failed Error=%d", mpp->alias, ret);
> -		free(resp);
> -		return  ret;
> +		goto out;
>  	}
>  
> +	ret = MPATH_PR_SUCCESS;
> +
>  	if (resp->prin_descriptor.prin_readkeys.additional_length == 0 )
>  	{
>  		condlog(3,"%s: No key found. Device may not be registered. ", mpp->alias);
> -		free(resp);
> -		return MPATH_PR_SUCCESS;
> +		goto out;
>  	}
>  
>  	condlog(2, "%s: Multipath  reservation_key: 0x%" PRIx64 " ", mpp->alias,
> @@ -795,6 +795,7 @@ int update_map_pr(struct multipath *mpp)
>  		condlog(2, "%s: prflag flag set.", mpp->alias );
>  	}
>  
> +out:
>  	free(resp);
> -	return MPATH_PR_SUCCESS;
> +	return ret;
>  }
> -- 
> 2.39.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