Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp55163imu; Thu, 8 Nov 2018 14:41:28 -0800 (PST) X-Google-Smtp-Source: AJdET5cDFs/9DvgL8lmsByaQI+XDAe4YR5mmQ8hDGhsBvmpuC2DkGwxuI5fCACuCZVPU1O/lhkQB X-Received: by 2002:a17:902:e193:: with SMTP id cd19-v6mr6420712plb.262.1541716888790; Thu, 08 Nov 2018 14:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716888; cv=none; d=google.com; s=arc-20160816; b=i+vjnTgEr5Xgtn1KSzte3dpk41oPFUQ9FYZfoZWAzalVVW6wUu8gisYxNosf1XHr2x BbXD4JTj8k62cf9duwumU7ouxochg4WFHP5mq89sCzcuvB7oMXQRdRreMmVQQPnJSgZA /GOR1TVw8FC1PXNlcOtM7efHcSNUDJxMj3eOSYIqrYrYlBCxVekO8v3V4FNmz6i5oCZr 8+aCnyKbhxg/M6qhclTPLtjR1YwA8VPc4VNTg3qRyk4lC5Xx4FVA+5AECVHTsOhkbRTU 2S2JinwCJEyYysxoz1n1CEL2LrlNSkDNcyxA00tGYPxOyER42fK7XXm+GHscnly/KylP Tpyw== 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=Mc1yE3Ssht4APWBsnfGCfdqBhV+VapHm51vap5GKpi0=; b=sFkqz1BVZxtSJEkHiqW4iC0+5RumMtxUIjaCNlgiexUd/9/sfICUb+hIPY4zGxi0ey tk2zdq4CGWyWVacQ0TCmet/tPxkQoCc0/4Ua5ZLgpTr6rOor9daVGqajvXSKsPSwNGL5 Dfr0EKJoG7ikoIgbq9C6Eo82RMkfzdQpKOWBuPes8QCp5uVS7K4KKdo/A7Xi/tCIdbp/ oOanGiphj2EJzrVWDheTEHLSL9K8ckVCIXMgT2ei8rTWMFnSWrwBlRh3sr0IGUl0znwp mR9wptVqmQJAPYB8TlEHXGXxmYSUbMGiQgGOeTo/VePKWLjFjbgkUovyxaWXMyviVTaR wK8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uwyhEX3G; 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 c85-v6si5744036pfe.60.2018.11.08.14.41.13; Thu, 08 Nov 2018 14:41:28 -0800 (PST) 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=uwyhEX3G; 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 S1728614AbeKIIRX (ORCPT + 99 others); Fri, 9 Nov 2018 03:17:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:50470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727463AbeKIHeC (ORCPT ); Fri, 9 Nov 2018 02:34:02 -0500 Received: from localhost (unknown [208.72.13.198]) (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 9538920892; Thu, 8 Nov 2018 21:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714194; bh=ZExUvJSTwHCZ3mlAePFowVOgZZOjZDF1gWFERXCa2Qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uwyhEX3GZ04XALR0namjrU75Nfjfj5d4BmUA7AqlAcXRPfrVKlPDC/pvwkl/k5OAI v3jfg8J3SYhXQNJA4jCYng9/xb4XSve4bmleib92Z7dTDu5qpVs35800YoNCYV8sgX CsOtYYL6mDBChu/SG21pyt2LSiTB0Kh+zYU2UWn4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Williamson , Bjorn Helgaas , Myron Stowe , Mark Rustad , Sasha Levin Subject: [PATCH 3.18 116/144] PCI: Fix devfn for VPD access through function 0 Date: Thu, 8 Nov 2018 13:51:27 -0800 Message-Id: <20181108215106.388149049@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215054.826084593@linuxfoundation.org> References: <20181108215054.826084593@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 9d9240756e63dd87d6cbf5da8b98ceb8f8192b55 ] Commit 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0") passes PCI_SLOT(devfn) for the devfn parameter of pci_get_slot(). Generally this works because we're fairly well guaranteed that a PCIe device is at slot address 0, but for the general case, including conventional PCI, it's incorrect. We need to get the slot and then convert it back into a devfn. Fixes: 932c435caba8 ("PCI: Add dev_flags bit to access VPD through function 0") Signed-off-by: Alex Williamson Signed-off-by: Bjorn Helgaas Acked-by: Myron Stowe Acked-by: Mark Rustad CC: stable@vger.kernel.org Signed-off-by: Sasha Levin --- drivers/pci/access.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 7f249b9ab2ce..2f15e7bb9f44 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -355,7 +355,8 @@ static const struct pci_vpd_ops pci_vpd_pci22_ops = { static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, void *arg) { - struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); + struct pci_dev *tdev = pci_get_slot(dev->bus, + PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); ssize_t ret; if (!tdev) @@ -369,7 +370,8 @@ static ssize_t pci_vpd_f0_read(struct pci_dev *dev, loff_t pos, size_t count, static ssize_t pci_vpd_f0_write(struct pci_dev *dev, loff_t pos, size_t count, const void *arg) { - struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); + struct pci_dev *tdev = pci_get_slot(dev->bus, + PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); ssize_t ret; if (!tdev) @@ -388,7 +390,8 @@ static const struct pci_vpd_ops pci_vpd_f0_ops = { static int pci_vpd_f0_dev_check(struct pci_dev *dev) { - struct pci_dev *tdev = pci_get_slot(dev->bus, PCI_SLOT(dev->devfn)); + struct pci_dev *tdev = pci_get_slot(dev->bus, + PCI_DEVFN(PCI_SLOT(dev->devfn), 0)); int ret = 0; if (!tdev) -- 2.17.1