From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 81457A09D3; Thu, 20 Oct 2022 11:20:09 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 394EF42CEA; Thu, 20 Oct 2022 11:20:09 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id C08FA42C7C for ; Thu, 20 Oct 2022 11:20:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666257607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OEYS9mVDu+lS3ItDuTgrw90qw1wKKT+3tSkHV0EQR1E=; b=WIoCTYsTxdpKJOxTWol+BU2lzrSDiElmcI9EkBESxyUDWp9WOQCXZzr6WosDDK5CbGIMtL 7hze9q9TonOIi2OX+Z73+jqUYkZYbuXZceufoWfLg24IsYYNfZvWKboduTwF1bwlpmx88x EKz3CR24NZ81P9pABUagM+kLXRm2k+k= Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-594-1BTJ2L4FPNCxQXamSRbmxQ-1; Thu, 20 Oct 2022 05:20:05 -0400 X-MC-Unique: 1BTJ2L4FPNCxQXamSRbmxQ-1 Received: by mail-pg1-f200.google.com with SMTP id p18-20020a63e652000000b0046b27534651so9697416pgj.17 for ; Thu, 20 Oct 2022 02:20:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OEYS9mVDu+lS3ItDuTgrw90qw1wKKT+3tSkHV0EQR1E=; b=mCd8nqiVFANAK4ac7UyXLhkaVV9UQahkvA8mFJKJISKzteB8SD5K9si976FVsQUZZo ab7HGrCAw3/PHVjfUfElxGNnZC/pDBNPRMB88mN5hPMOT79y9xmgTaHqLKWLsBNftTND O17EcpMItKwHMjlPjL8VILEFweQSLRHnFG5dcspRrVWN7FxZOSwvM7wmnRHcf9eozf8I bN8S+0ascSMvfnmyR9z+Lgoo6j8uxj/Gbpb86thhhLTsr9LST1YE8sokrhIy2WT+4s2C phl4fSZTD95xKhCvnKQIZp84O+L1V0tvGuyk2GMKXAy53LC+rFCCQUAq6xbBpTPq1tIg TDrQ== X-Gm-Message-State: ACrzQf1QMIVM1oxStr+XyaHWXhsIOphuj5Zo2PHYG0Rykt+sAsTfwbt5 hLAyBl8zfPsPsZzl9a1eIf4am+THqUBEKfwjW1k4FqNMdxzpIIx8H3pzQaZYp7y4NGI/Y9wBvma Z0aw1ne22NTgduOL2E8M= X-Received: by 2002:a17:90a:428e:b0:205:d5fe:e0b3 with SMTP id p14-20020a17090a428e00b00205d5fee0b3mr14808003pjg.33.1666257604673; Thu, 20 Oct 2022 02:20:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4qpSUHQoAuXpGE5hf7C4GzWx7Ok0d7+p07cXZSm0J5TkpiiAIBjDs3pjwA2gtN24hPYM69L2LYRhHUTwK6YD8= X-Received: by 2002:a17:90a:428e:b0:205:d5fe:e0b3 with SMTP id p14-20020a17090a428e00b00205d5fee0b3mr14807985pjg.33.1666257604422; Thu, 20 Oct 2022 02:20:04 -0700 (PDT) MIME-Version: 1.0 References: <20221019104923.1240394-1-kevin.laatz@intel.com> <20221019123743.1282969-1-kevin.laatz@intel.com> In-Reply-To: <20221019123743.1282969-1-kevin.laatz@intel.com> From: David Marchand Date: Thu, 20 Oct 2022 11:19:52 +0200 Message-ID: Subject: Re: [PATCH v2] bus: fix memleak during pci device cleanup To: Kevin Laatz Cc: dev@dpdk.org, =?UTF-8?Q?Morten_Br=C3=B8rup?= , Bruce Richardson X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Wed, Oct 19, 2022 at 2:35 PM Kevin Laatz wrote: > > During PCI bus device cleanup some interrupt handle pointers and the > bus_info pointer are not being free'd, leading to memory leaks. > This patch fixes the memory leaks by ensuring they are free'd during > device cleanup on exit. > > Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown") > > Signed-off-by: Kevin Laatz > > --- > v2: remove redundant NULL checks > --- > drivers/bus/pci/pci_common.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c > index 7f598667fe..71cd3f59ad 100644 > --- a/drivers/bus/pci/pci_common.c > +++ b/drivers/bus/pci/pci_common.c > @@ -456,6 +456,16 @@ pci_cleanup(void) > } > dev->driver = NULL; > dev->device.driver = NULL; > + > + /* free interrupt handles */ > + rte_intr_instance_free(dev->intr_handle); > + dev->intr_handle = NULL; > + rte_intr_instance_free(dev->vfio_req_intr_handle); > + dev->vfio_req_intr_handle = NULL; > + > + free(dev->bus_info); > + dev->bus_info = NULL; > + > free(dev); I'll do an update when applying: here, it is better to use pci_free(dev); which was introduced at the same time bus_info was. > } > > -- > 2.31.1 > Reviewed-by: David Marchand -- David Marchand