Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4086576ybi; Mon, 3 Jun 2019 05:34:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCziuicHa11g88f6eCrexAYnj7TSKTBId3KsXdeluLJvn0dc77buwFWLtyIq3zIB+ZWVef X-Received: by 2002:a17:90a:8982:: with SMTP id v2mr29317797pjn.136.1559565265648; Mon, 03 Jun 2019 05:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559565265; cv=none; d=google.com; s=arc-20160816; b=HT+raIXYoIdzEJ0ehpT0WGSbkgveHqYz6mqJBEQM2Bw+lt1IlboQrFGAI5Ku7NRHJZ QxxG/qMOrUrK6AluTgGelMuZGBS/Auh58trYo6kJYWwl4SjcALopb1fHfljolf3g9e23 pxd8MpNi2JP8oRk++mxVcpvv2rBvod5apt5WkTcn/NY7MCE4edfkend+n6GmtmOHHy3s azt+T+vZJc7RNbkMJuWRVoTEVbXb0SUCbW2d6+o++z5W5xTKohBw1pRRY8bLERzNOqWU E4C1MuIU2es8foDdQpOcD+FaT/m2vP7H+QonPTDhiAvYIHB4QxfSwRISZf0gvStIOW13 qwmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:subject:cc:from:to :in-reply-to; bh=xIcGo8gwYa8b6cJiKmlhij35ogxIEvm2uUbEcJ59STs=; b=HuVdW7yXiQP1ILSgPh2nvIvm29meSklsNpskgqJg6dunaMBQf+kNs4sVXsdvM494TZ kAB6wjNdC+BzfeB406M0m/wHbNQ82oJLzPdtoMIwhFAmOIkk5qTM8jIfuSNqbEJ2KSJg CBEmOI8d+fO12TDZp/3kQybSuQf2c69OfgRoOgvTGXmJ6221tp1Pf9hAQ2aLFZ2ejA6b e3+qo0U8/n/elKC1nUWRpt0uFO8+6Pc36lrQnyazVxUTmtNLjxz4Z4r8494RRUXYOdrQ gnUQ8ohhXIHkr1GwdNnR4rWUGp48XKCBlIGEgW0HF5ZAaIW1yeCsqs8nxrWwHNqaph2Z feAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m19si16940046pgj.149.2019.06.03.05.34.08; Mon, 03 Jun 2019 05:34:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727381AbfFCMcu (ORCPT + 99 others); Mon, 3 Jun 2019 08:32:50 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:38091 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfFCMcs (ORCPT ); Mon, 3 Jun 2019 08:32:48 -0400 Received: by ozlabs.org (Postfix, from userid 1034) id 45HZFp6yhxz9s7h; Mon, 3 Jun 2019 22:32:46 +1000 (AEST) X-powerpc-patch-notification: thanks X-powerpc-patch-commit: 02c5f5394918b9b47ff4357b1b18335768cd867d X-Patchwork-Hint: ignore Content-Type: text/plain; charset="utf-8"; In-Reply-To: <155568805354.600470.13376593185688810607.stgit@bahia.lan> To: Greg Kurz , linux-kernel@vger.kernel.org From: Michael Ellerman Cc: Alexey Kardashevskiy , linuxppc-dev@lists.ozlabs.org, Alistair Popple Subject: Re: [PATCH] powerpc/powernv/npu: Fix reference leak Message-Id: <45HZFp6yhxz9s7h@ozlabs.org> Date: Mon, 3 Jun 2019 22:32:46 +1000 (AEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-04-19 at 15:34:13 UTC, Greg Kurz wrote: > Since 902bdc57451c, get_pci_dev() calls pci_get_domain_bus_and_slot(). This > has the effect of incrementing the reference count of the PCI device, as > explained in drivers/pci/search.c: > > * Given a PCI domain, bus, and slot/function number, the desired PCI > * device is located in the list of PCI devices. If the device is > * found, its reference count is increased and this function returns a > * pointer to its data structure. The caller must decrement the > * reference count by calling pci_dev_put(). If no device is found, > * %NULL is returned. > > Nothing was done to call pci_dev_put() and the reference count of GPU and > NPU PCI devices rockets up. > > A natural way to fix this would be to teach the callers about the change, > so that they call pci_dev_put() when done with the pointer. This turns > out to be quite intrusive, as it affects many paths in npu-dma.c, > pci-ioda.c and vfio_pci_nvlink2.c. Also, the issue appeared in 4.16 and > some affected code got moved around since then: it would be problematic > to backport the fix to stable releases. > > All that code never cared for reference counting anyway. Call pci_dev_put() > from get_pci_dev() to revert to the previous behavior. > > Fixes: 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary pcidev from pci_dn") > Cc: stable@vger.kernel.org # v4.16 > Signed-off-by: Greg Kurz > Reviewed-by: Alexey Kardashevskiy Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/02c5f5394918b9b47ff4357b1b183357 cheers