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 D799FA0584; Wed, 19 Oct 2022 13:40:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C769B427F3; Wed, 19 Oct 2022 13:40:19 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id C298240695 for ; Wed, 19 Oct 2022 13:40:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666179617; 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=X+fvGb6T2cNFyR+inTTbA74JesrMpbY/fZ6N4aWIhzw=; b=GZ2O/QwPl/BXiP6kAH8pUnw1Z3Q1GILHZGWWfF4bl+dIY+eAAt3K0yc9bxvb3ZWzZrL6Ro UsB25/VLPcrMw0Q2E6F8mQBrY5/rQTXAi5MsXOHtb5njVbPOUWFSFE/6lO0fVmtmJOm+au U1HG3fvqLFvExjoVBQmUWmlsWgjxbAQ= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-533-ogATcCQgPuKwXE84k6xLOw-1; Wed, 19 Oct 2022 07:40:16 -0400 X-MC-Unique: ogATcCQgPuKwXE84k6xLOw-1 Received: by mail-pj1-f70.google.com with SMTP id b1-20020a17090a10c100b0020da29fa5e5so8185165pje.2 for ; Wed, 19 Oct 2022 04:40:16 -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=X+fvGb6T2cNFyR+inTTbA74JesrMpbY/fZ6N4aWIhzw=; b=5ie8rcPS5UC49gy0Ta1LpmqL/Db9p6T8mSII7P4FPR2QvQcXwOSHlTDK18Ptos9xiw 4SMHhUK2rEDhK0B9qd31g2KKk3ska7DvJI8tw0f8GI9bXQzvh2MgISvKZ8zgR31JBeLg LLgcvI3pUMyRDVISaDRebG8FkytcMijSjDDg5WeldbGdNZ2L14slq9TMegZqjYFf0pkQ hICczwEkaJcMpjdW5TBrfXOw0RWtzB9UHpMbe5nuhp9p/vMkhuNaEkUFWjI6n5EOdKTw dAgpTHnXD5cPcdGbP7AHxQeaJP7ij+h3jUKb+SubMiG+KLnX8j/+CB4czf2aMSZ5U925 5pTw== X-Gm-Message-State: ACrzQf2eRXAa9zRiQ8/XP9KBKGCK3jICiN5Do08R38fm9+xD02O0ey5K 2IOFI1KPAjYjI6ttU9rt1MjD1lVLfbb70fVie7oBAs3XiEiBPom3WR3JBwpvL4WgF3/ubO1b3l8 QI/xxZ+aPzg7jFJWvxho= X-Received: by 2002:a17:902:bf46:b0:179:eba5:90ba with SMTP id u6-20020a170902bf4600b00179eba590bamr7986568pls.16.1666179615326; Wed, 19 Oct 2022 04:40:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5IA0NZ/OPGAgTuCLlfqNWxVWyR9DSOencv3gN+jCbMqEX4v9MW932EXpJHz2HBzEQ+/Z1U2Ed8Ql7/xBkLlIk= X-Received: by 2002:a17:902:bf46:b0:179:eba5:90ba with SMTP id u6-20020a170902bf4600b00179eba590bamr7986546pls.16.1666179615058; Wed, 19 Oct 2022 04:40:15 -0700 (PDT) MIME-Version: 1.0 References: <20221019104923.1240394-1-kevin.laatz@intel.com> In-Reply-To: <20221019104923.1240394-1-kevin.laatz@intel.com> From: David Marchand Date: Wed, 19 Oct 2022 13:40:03 +0200 Message-ID: Subject: Re: [PATCH] bus: fix memleak during pci device cleanup To: Kevin Laatz Cc: dev@dpdk.org, Bruce Richardson , =?UTF-8?Q?Morten_Br=C3=B8rup?= 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 12:46 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 > --- > drivers/bus/pci/pci_common.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c > index 7f598667fe..330a41ed12 100644 > --- a/drivers/bus/pci/pci_common.c > +++ b/drivers/bus/pci/pci_common.c > @@ -456,6 +456,20 @@ pci_cleanup(void) > } > dev->driver = NULL; > dev->device.driver = NULL; > + > + /* free interrupt handles */ > + if (dev->intr_handle != NULL) { rte_intr_instance_free already handles NULL, no need for the check. > + 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; > + } > + > + if (dev->bus_info != NULL) { Idem. > + free(dev->bus_info); > + dev->bus_info = NULL; > + } > + > free(dev); > } > > -- > 2.31.1 > -- David Marchand