From patchwork Wed Sep 9 05:17:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 515701 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 951CB14056B for ; Wed, 9 Sep 2015 15:21:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.b=aT1p358J; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 6F1801A2780 for ; Wed, 9 Sep 2015 15:21:58 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.b=aT1p358J; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 020581A2354 for ; Wed, 9 Sep 2015 15:20:37 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.b=aT1p358J; dkim-atps=neutral Received: by ozlabs.org (Postfix) id E0A34140761; Wed, 9 Sep 2015 15:20:36 +1000 (AEST) Delivered-To: linuxppc-dev@ozlabs.org Received: from mail-pa0-x230.google.com (mail-pa0-x230.google.com [IPv6:2607:f8b0:400e:c03::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B99C7140663 for ; Wed, 9 Sep 2015 15:20:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.b=aT1p358J; dkim-atps=neutral Received: by padhk3 with SMTP id hk3so61075522pad.3 for ; Tue, 08 Sep 2015 22:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id; bh=22Dj10qAgxxxNpM7S14LQFAkZWbGQzEbzIDyuelY+7w=; b=aT1p358JMDhkBdwQOAGuilYq37qP4mFznjkgE5GHjjWTiEBhmRHkpXVN7mUiZnZ/3/ 8RD6Hw8igQCpGyocGTUGw5LoWhzlzM/nXoQSlzuKvowansPovGeYH19o5FNXKj3lYiP3 0YozvzilmjZANOVSp5z6mZWBhKVrCUs2n5s1E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=22Dj10qAgxxxNpM7S14LQFAkZWbGQzEbzIDyuelY+7w=; b=RnsAPX+ZTtybH3p71kubKXviwQczIX72ZcUKTLVz8HuIR+KzozCSc6rel9AsSqieQh /1RtYVzASdOsVbN/KqyivpqWihdvzc8cHNXidxSKVV2ZfoqSL1VR2kXwHxNqIVY2Fswo N2cFXZztnzyYhd7FRjKzkkZPfISsOxUhvtkjngrbb8mIdw+g0nRgvCzlCAkGjhT13WyZ 7v+5SVgT/YC/dg14FZNgCTphsADKmTgWXjNChwIv4Qpd0zvlydzPO07S7w+mDioN65om 3M4e6R9mVuvsYiBvjXIUg17dykCl2sNd2Noqq+hlp2gOQFRwz0FrvLdb9awwafJYwhvE Bc8Q== X-Gm-Message-State: ALoCoQn9X8yshX7qA3o+To+0EWSqWMw9E2eoj5WrDu22cSG1O0QkTWg4uFaMokfhpjPldWIHoI1V X-Received: by 10.68.98.34 with SMTP id ef2mr66004676pbb.45.1441776033522; Tue, 08 Sep 2015 22:20:33 -0700 (PDT) Received: from gamma.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id eg1sm1466982pbc.21.2015.09.08.22.20.29 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 08 Sep 2015 22:20:32 -0700 (PDT) From: Daniel Axtens To: linuxppc-dev@ozlabs.org Subject: [PATCH] cxl: Fix unbalanced pci_dev_get in cxl_probe Date: Wed, 9 Sep 2015 15:17:25 +1000 Message-Id: <1441775845-25870-1-git-send-email-dja@axtens.net> X-Mailer: git-send-email 2.5.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mikey@neuling.org, imunsie@au.ibm.com, andrew.donnellan@au1.ibm.com, Daniel Axtens MIME-Version: 1.0 Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Currently the first thing we do in cxl_probe is to grab a reference on the pci device. Later on, we call device_register on our adapter, which also holds the PCI device. In our remove path, we call device_unregister, but we never call pci_dev_put. We therefore leak the device every time we do a reflash. device_register/unregister is sufficient to hold the reference. Drop the call to pci_dev_get. Fixes: f204e0b8cedd ("cxl: Driver code for powernv PCIe based cards for userspace access") Cc: stable@vger.kernel.org Signed-off-by: Daniel Axtens Acked-by: Ian Munsie --- This is the cxl bug that caused me to catch this a few weeks back: e642d11bdbfe ("powerpc/eeh: Probe after unbalanced kref check") I put an printk in the unbalanced kref path and confirmed that it was printed with the pci_dev_get in and went away with the pci_dev_get out. --- drivers/misc/cxl/pci.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index 02c85160bfe9..a5e977192b61 100644 --- a/drivers/misc/cxl/pci.c +++ b/drivers/misc/cxl/pci.c @@ -1249,8 +1249,6 @@ static int cxl_probe(struct pci_dev *dev, const struct pci_device_id *id) int slice; int rc; - pci_dev_get(dev); - if (cxl_verbose) dump_cxl_config_space(dev);