Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3788087ybi; Mon, 29 Jul 2019 12:37:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNwl3wHd/Pbv+hN4E68iUl5DqVtHBuouZ6pjZ4yuAYZ/izuC6BCJ/cIzn/tl/30/TndA8T X-Received: by 2002:a17:902:e2:: with SMTP id a89mr112458364pla.210.1564429073604; Mon, 29 Jul 2019 12:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429073; cv=none; d=google.com; s=arc-20160816; b=OKvQGA0+b2Ik/toZYF06M2RyHQ6lbDF8WWXehigOsgZUlFubaVVEzvAkpJxIJxdXo8 qtvURV31VDuFkjFs8uJ3YR8cFgC0QVDaA0ZGPlf83t9yGFumZVzPBV41PQhdrsZUkXIx Zrtera9tQ4rJVGQ8Fw3zz83M5xZk7yaR1v8Qq8+KuOxFXBFAy12JUvdqFj6enzKqh2/c IMkkRrqahvMurs3Qr/9TzvuuR0ZThfRB07HpfTv5j7GJthHiio4Zs901kORCmw87mGQW R+IOJBs96LMiANVZdGx/1owdVCvKRfGUBIig3mkVNwN6VzSRvRPu353Q2p+4z4w75+kO 8Okw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tx1qhFP6rvhRQAgizUuVF/KAth4ViyWjvfX50HE6aQs=; b=skOH6zFakz2mTx7QrQ7CpNGtL+eTJYaMAb8FK9vCltBsbbGnG+ehWQtyrLUA3JGs+g PiHN1vEF2/0jKrIuPbEGeFx3m7zks8fMhJ3ZdRLw4bs2DbcU9gSr/+nDHYLWZE1kbZRp LcWs96Vscus1qTVE+RYC+aBsjGFPT0SgasDcXCcWrLEJHj3hoAJKak8Ijj5dks/hrLtw CAExJV54gNtZUEON8p7bwmuQbmQyR6SmOoqvdiwapBkuLNB7fA8X3Fm7tVHqvfLuz8/h z7di8JQXpUuXnLgMRlGcC72sfk+Z2EQ59E28fbDBUaWKioYoMt22oRFvBUB3YiOFcoYU OR3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yuskjZW8; 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 x61si27107803plb.336.2019.07.29.12.37.38; Mon, 29 Jul 2019 12:37:53 -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; dkim=pass header.i=@kernel.org header.s=default header.b=yuskjZW8; 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 S2387957AbfG2TgU (ORCPT + 99 others); Mon, 29 Jul 2019 15:36:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:50624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388572AbfG2TgQ (ORCPT ); Mon, 29 Jul 2019 15:36:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D87512171F; Mon, 29 Jul 2019 19:36:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428975; bh=88T8WQy+9gKqfooyuekwAxRjIY12W/zte00sVRrZulk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yuskjZW8kFqmeJ4ABEuTFh6HeBi8dW4yyvCRaX7JwV212nJ3aqRhBMfRzYGs3bJ+J 3oBxffR4CCkkF/m65srF5gFqG3Vk4q30kJ9PM9+BFIVnS343Kx5z7T1LS9xhsYojjF UysPXca4WUhO46+vfA/gMZIHc3gU7hMtGuBRCFSM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Williamson , Bjorn Helgaas , Sasha Levin Subject: [PATCH 4.14 228/293] PCI: Return error if cannot probe VF Date: Mon, 29 Jul 2019 21:21:59 +0200 Message-Id: <20190729190841.960852238@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 76002d8b48c4b08c9bd414517dd295e132ad910b ] Commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to control VF driver binding") allows the user to specify that drivers for VFs of a PF should not be probed, but it actually causes pci_device_probe() to return success back to the driver core in this case. Therefore by all sysfs appearances the device is bound to a driver, the driver link from the device exists as does the device link back from the driver, yet the driver's probe function is never called on the device. We also fail to do any sort of cleanup when we're prohibited from probing the device, the IRQ setup remains in place and we even hold a device reference. Instead, abort with errno before any setup or references are taken when pci_device_can_probe() prevents us from trying to probe the device. Link: https://lore.kernel.org/lkml/155672991496.20698.4279330795743262888.stgit@gimli.home Fixes: 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to control VF driver binding") Signed-off-by: Alex Williamson Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- drivers/pci/pci-driver.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index ea69b4dbab66..e5a8bf2c9b37 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -415,6 +415,9 @@ static int pci_device_probe(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_driver *drv = to_pci_driver(dev->driver); + if (!pci_device_can_probe(pci_dev)) + return -ENODEV; + pci_assign_irq(pci_dev); error = pcibios_alloc_irq(pci_dev); @@ -422,12 +425,10 @@ static int pci_device_probe(struct device *dev) return error; pci_dev_get(pci_dev); - if (pci_device_can_probe(pci_dev)) { - error = __pci_device_probe(drv, pci_dev); - if (error) { - pcibios_free_irq(pci_dev); - pci_dev_put(pci_dev); - } + error = __pci_device_probe(drv, pci_dev); + if (error) { + pcibios_free_irq(pci_dev); + pci_dev_put(pci_dev); } return error; -- 2.20.1