Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4341707ybi; Tue, 30 Jul 2019 00:16:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjA5qwpnFi9P6EtmrJ6HBHe1Km0+YEvQJNdpSavHHsrgZ582OeH5szBmVKZS6egAoraY8N X-Received: by 2002:a63:6686:: with SMTP id a128mr99711019pgc.361.1564470967796; Tue, 30 Jul 2019 00:16:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564470967; cv=none; d=google.com; s=arc-20160816; b=jKOgkQem5FNI2QJFvxwGut4LPZxgY3pK8ru910LUpmr4p9IQu6gH+BUwEE/gqWOCRx 9Wpc/geZ68zjEt3uYtQpYan8f2EWA6/hn7rrZcNfxsnTsjR/O6yxBCPVUIUZOvosPJ9G cgVNtyqhm8qGmkamWjWKub+RtvjbI9uZC1mIdtxvCUJmRkQMSHH3dFgeT/u3biA7kl39 ADdXfhlb1BO313aqADpRqphB0fLFQ1xeFQfU9tkvJmSKb3JL/7hL2gkmsKu9Dto/zcBD XBe5Zlr60zhLL5v2qX+jpYCi/9PaoVTcZ0K7sB2X7Ku3Qa2vKRTwSaXj+BpyrloV8RGl 7pRQ== 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=cwOEpIlaM4tthVgAJ9op6Sd3/zC+9wJIKkTdB0LLqO4=; b=VSU5/qkjEGpmZ6MXZuJB1ha/VdrivjnlWcMaYYaEzSeNNN7x9oPqCBXmD3pOHi2zcX ZH0RGPEMwtJThgdOQeGfZugNcaT9WPCRma0VG9lZUDu85NBPPdAdXG9aMAjai2Z8XV8K M+0MlS0LLaIYnLb0wR0qx/QRq28vJzYL3kmFpvKFkfJnc1HyqI+WMNUmC2/biLHIzLTN t/gTp1PoLbCcifZfAKYQa9q4angBZ1+XyjrnezP09l8sFnNnrkYkB2VHxPRAWvZfFgte lnbUvtfDVTwq1579qwgE7qRaZ31vmynMWXT5c9GzDf1+cnlVuOJTsx/f0DxGWKriLLOs 0eBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PtBLljVM; 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 e2si27915025pgf.256.2019.07.30.00.15.53; Tue, 30 Jul 2019 00:16:07 -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=PtBLljVM; 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 S1730092AbfG2UHV (ORCPT + 99 others); Mon, 29 Jul 2019 16:07:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:54780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388589AbfG2Tjg (ORCPT ); Mon, 29 Jul 2019 15:39:36 -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 D23D8206DD; Mon, 29 Jul 2019 19:39:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429176; bh=slMhLLzF0Lqf1ggD9BjMAZtuBRfrx1kN0uNY1MqkJ5E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PtBLljVMYxrAkMnJxMGIJx3DoUZw1cKgM30fNyDk6T+xFNnU1TchK4yEuP0d4KXAw BUxGoGVwvmAKcuFcLcqg6vNnBRXDk+Iqr57w3DkYMMPRCT9VByBPu97Yqwcs7bldW4 +cWWaPc10jA6OUBMXXgXsWs4xwL07msAap8iWfUU= 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.19 016/113] PCI: Return error if cannot probe VF Date: Mon, 29 Jul 2019 21:21:43 +0200 Message-Id: <20190729190659.676178730@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 33f3f475e5c6..956ee7527d2c 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -414,6 +414,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); @@ -421,12 +424,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