From owner-svn-src-stable-12@freebsd.org Thu Sep 5 09:20:15 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EA217DFFA6; Thu, 5 Sep 2019 09:20:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46PFXH5wvWz4SWB; Thu, 5 Sep 2019 09:20:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AD2B91D01; Thu, 5 Sep 2019 09:20:15 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x859KF3b016741; Thu, 5 Sep 2019 09:20:15 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x859KFbD016740; Thu, 5 Sep 2019 09:20:15 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201909050920.x859KFbD016740@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 5 Sep 2019 09:20:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351838 - stable/12/sys/compat/linuxkpi/common/src X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/compat/linuxkpi/common/src X-SVN-Commit-Revision: 351838 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Sep 2019 09:20:16 -0000 Author: hselasky Date: Thu Sep 5 09:20:15 2019 New Revision: 351838 URL: https://svnweb.freebsd.org/changeset/base/351838 Log: MFC r347387: Fix memory leak of PCI BUS structure in the LinuxKPI. Sponsored by: Mellanox Technologies Modified: stable/12/sys/compat/linuxkpi/common/src/linux_pci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linuxkpi/common/src/linux_pci.c ============================================================================== --- stable/12/sys/compat/linuxkpi/common/src/linux_pci.c Thu Sep 5 09:04:48 2019 (r351837) +++ stable/12/sys/compat/linuxkpi/common/src/linux_pci.c Thu Sep 5 09:20:15 2019 (r351838) @@ -171,12 +171,10 @@ linux_pci_attach(device_t dev) pdev->dev.irq = LINUX_IRQ_INVALID; pdev->irq = pdev->dev.irq; - if (pdev->bus == NULL) { - pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO); - pbus->self = pdev; - pbus->number = pci_get_bus(dev); - pdev->bus = pbus; - } + pbus = malloc(sizeof(*pbus), M_DEVBUF, M_WAITOK | M_ZERO); + pbus->self = pdev; + pbus->number = pci_get_bus(dev); + pdev->bus = pbus; spin_lock(&pci_lock); list_add(&pdev->links, &pci_devices); @@ -184,6 +182,7 @@ linux_pci_attach(device_t dev) error = pdrv->probe(pdev, id); if (error) { + free(pdev->bus, M_DEVBUF); spin_lock(&pci_lock); list_del(&pdev->links); spin_unlock(&pci_lock); @@ -202,6 +201,7 @@ linux_pci_detach(device_t dev) pdev = device_get_softc(dev); pdev->pdrv->remove(pdev); + free(pdev->bus, M_DEVBUF); spin_lock(&pci_lock); list_del(&pdev->links);