From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PATCH] iommu/ipmmu-vmsa: Fix potential memleak Date: Mon, 22 Aug 2016 12:42:45 +0200 Message-ID: <20160822104245.GL1437@8bytes.org> References: <1471854877-15114-1-git-send-email-shawn.lin@rock-chips.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1471854877-15114-1-git-send-email-shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Shawn Lin Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: iommu@lists.linux-foundation.org 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 > --- > > 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