Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1173583

Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure

From Alexey Kardashevskiy <aik@ozlabs.ru>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in tce_iommu_attach_group() after kzalloc() failure
Date 2015-06-29 01:50 +0200
Message-ID <pGuuK-2zg-3@gated-at.bofh.it> (permalink)
References (14 earlier) <mSsDN-4wa-63@gated-at.bofh.it> <mSsDN-4wa-65@gated-at.bofh.it> <mSsDN-4wa-33@gated-at.bofh.it> <pGntf-138-9@gated-at.bofh.it> <pGnCV-1er-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 06/29/2015 02:24 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Jun 2015 17:58:42 +0200
>
> The kfree() function was called even if a previous memory allocation
> try failed.

tcegrp will be NULL and kfree() can handle this just fine (is not it the 
whole point of this patchset - remove the check and just call kfree() even 
if the pointer is NULL?). And if you wanted another label, than the 
existing one should have been renamed to "free_exit" or "free_unlock_exit" 
and new one would be "unlock_exit".



> This implementation detail could be improved by the introduction
> of another jump label.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/vfio/vfio_iommu_spapr_tce.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
> index 50ddfac..2523075 100644
> --- a/drivers/vfio/vfio_iommu_spapr_tce.c
> +++ b/drivers/vfio/vfio_iommu_spapr_tce.c
> @@ -1200,7 +1200,7 @@ static int tce_iommu_attach_group(void *iommu_data,
>   	tcegrp = kzalloc(sizeof(*tcegrp), GFP_KERNEL);
>   	if (!tcegrp) {
>   		ret = -ENOMEM;
> -		goto unlock_exit;
> +		goto unlock_container;
>   	}
>
>   	if (!table_group->ops || !table_group->ops->take_ownership ||
> @@ -1217,7 +1217,7 @@ static int tce_iommu_attach_group(void *iommu_data,
>   unlock_exit:
>   	if (ret)
>   		kfree(tcegrp);
> -
> +unlock_container:
>   	mutex_unlock(&container->lock);
>
>   	return ret;
>


-- 
Alexey
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH 2/2] vfio: powerpc/spapr: One function call less in  tce_iommu_attach_group() after kzalloc() failure Alexey Kardashevskiy <aik@ozlabs.ru> - 2015-06-29 01:50 +0200
  Re: vfio: powerpc/spapr: One function call less in  tce_iommu_attach_group() after kzalloc() failure Alexey Kardashevskiy <aik@ozlabs.ru> - 2015-06-30 02:40 +0200
    Re: vfio: powerpc/spapr: One function call less in  tce_iommu_attach_group() after kzalloc() failure Alexey Kardashevskiy <aik@ozlabs.ru> - 2015-06-30 12:40 +0200

csiph-web