All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/ipmmu-vmsa: Fix potential memleak
@ 2016-08-22  8:34 Shawn Lin
       [not found] ` <1471854877-15114-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Shawn Lin @ 2016-08-22  8:34 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, Shawn Lin

Let's free utlbs for the error routine.

Signed-off-by: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
---

 drivers/iommu/ipmmu-vmsa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index 2fdbac6..2458208 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -635,8 +635,10 @@ static int ipmmu_add_device(struct device *dev)
 
 	spin_unlock(&ipmmu_devices_lock);
 
-	if (ret < 0)
+	if (ret < 0) {
+		kfree(utlbs);
 		return -ENODEV;
+	}
 
 	for (i = 0; i < num_utlbs; ++i) {
 		if (utlbs[i] >= mmu->num_utlbs) {
-- 
2.3.7

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/ipmmu-vmsa: Fix potential memleak
       [not found] ` <1471854877-15114-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
@ 2016-08-22 10:42   ` Joerg Roedel
  0 siblings, 0 replies; 2+ messages in thread
From: Joerg Roedel @ 2016-08-22 10:42 UTC (permalink / raw)
  To: Shawn Lin; +Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA

On Mon, Aug 22, 2016 at 04:34:37PM +0800, Shawn Lin wrote:
> Let's free utlbs for the error routine.
> 
> Signed-off-by: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
> ---
> 
>  drivers/iommu/ipmmu-vmsa.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
> index 2fdbac6..2458208 100644
> --- a/drivers/iommu/ipmmu-vmsa.c
> +++ b/drivers/iommu/ipmmu-vmsa.c
> @@ -635,8 +635,10 @@ static int ipmmu_add_device(struct device *dev)
>  
>  	spin_unlock(&ipmmu_devices_lock);
>  
> -	if (ret < 0)
> +	if (ret < 0) {
> +		kfree(utlbs);
>  		return -ENODEV;
> +	}

This function has an error-out path that you can use here. This will
also correctply propagate the ret-value to the callers.



	Joerg

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-22 10:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-22  8:34 [PATCH] iommu/ipmmu-vmsa: Fix potential memleak Shawn Lin
     [not found] ` <1471854877-15114-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-08-22 10:42   ` Joerg Roedel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.