Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751494AbaDAHX5 (ORCPT ); Tue, 1 Apr 2014 03:23:57 -0400 Received: from nat28.tlf.novell.com ([130.57.49.28]:60828 "EHLO nat28.tlf.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751035AbaDAHX4 convert rfc822-to-8bit (ORCPT ); Tue, 1 Apr 2014 03:23:56 -0400 Message-Id: <533A85A70200007800003F59@nat28.tlf.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.0.0 Date: Tue, 01 Apr 2014 08:23:51 +0100 From: "Jan Beulich" To: "Daeseok Youn" , Cc: , , , , Subject: Re: [Xen-devel] [PATCH] xen: fix memory leak in __xen_pcibk_add_pci_dev() References: <2186395.ZOncrV6nFS@daeseok-laptop.cloud.net> In-Reply-To: <2186395.ZOncrV6nFS@daeseok-laptop.cloud.net> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>> On 31.03.14 at 12:08, wrote: > It need to free dev_entry when it failed to assign to a new > slot on the virtual PCI bus. > > smatch says: > drivers/xen/xen-pciback/vpci.c:142 __xen_pcibk_add_pci_dev() warn: > possible memory leak of 'dev_entry' > > Signed-off-by: Daeseok Youn Reviewed-by: Jan Beulich albeit the solution is not ideal: > --- a/drivers/xen/xen-pciback/vpci.c > +++ b/drivers/xen/xen-pciback/vpci.c > @@ -130,6 +130,7 @@ static int __xen_pcibk_add_pci_dev(struct > xen_pcibk_device *pdev, > err = -ENOMEM; > xenbus_dev_fatal(pdev->xdev, err, > "No more space on root virtual PCI bus"); > + kfree(dev_entry); > > unlock: > mutex_unlock(&vpci_dev->lock); The kfree() invocation would better be placed outside the locked region (e.g. in an else to the "if (!err)" a little further down). Jan -- 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/