Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/812242/?format=api
{ "id": 812242, "url": "http://patchwork.ozlabs.org/api/patches/812242/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20170911074542.16777-2-nstange@suse.de/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api", "name": "Linux PCI development", "link_name": "linux-pci", "list_id": "linux-pci.vger.kernel.org", "list_email": "linux-pci@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170911074542.16777-2-nstange@suse.de>", "list_archive_url": null, "date": "2017-09-11T07:45:40", "name": "[1/3] PCI: fix race condition with driver_override", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "7e193e58aea77b1d49023b7d2deb92059ad2f301", "submitter": { "id": 72345, "url": "http://patchwork.ozlabs.org/api/people/72345/?format=api", "name": "Nicolai Stange", "email": "nstange@suse.de" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20170911074542.16777-2-nstange@suse.de/mbox/", "series": [ { "id": 2449, "url": "http://patchwork.ozlabs.org/api/series/2449/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=2449", "date": "2017-09-11T07:45:39", "name": "make PCI's and platform's driver_override_store()/show() converge", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/2449/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/812242/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/812242/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linux-pci-owner@vger.kernel.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=linux-pci-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xrKkH0rmsz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 11 Sep 2017 17:46:31 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751090AbdIKHpu (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tMon, 11 Sep 2017 03:45:50 -0400", "from mx2.suse.de ([195.135.220.15]:47683 \"EHLO mx1.suse.de\"\n\trhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP\n\tid S1751031AbdIKHpt (ORCPT <rfc822;linux-pci@vger.kernel.org>);\n\tMon, 11 Sep 2017 03:45:49 -0400", "from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254])\n\tby mx1.suse.de (Postfix) with ESMTP id D0507ABBF;\n\tMon, 11 Sep 2017 07:45:47 +0000 (UTC)" ], "X-Virus-Scanned": "by amavisd-new at test-mx.suse.de", "From": "Nicolai Stange <nstange@suse.de>", "To": "Bjorn Helgaas <bhelgaas@google.com>,\n\tGreg Kroah-Hartman <gregkh@linuxfoundation.org>", "Cc": "Adrian Salido <salidoa@google.com>, Sasha Levin <sasha.levin@oracle.com>,\n\tlinux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,\n\tNicolai Stange <nstange@suse.de>", "Subject": "[PATCH 1/3] PCI: fix race condition with driver_override", "Date": "Mon, 11 Sep 2017 09:45:40 +0200", "Message-Id": "<20170911074542.16777-2-nstange@suse.de>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170911074542.16777-1-nstange@suse.de>", "References": "<20170911074542.16777-1-nstange@suse.de>", "Sender": "linux-pci-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<linux-pci.vger.kernel.org>", "X-Mailing-List": "linux-pci@vger.kernel.org" }, "content": "The driver_override implementation is susceptible to a race condition when\ndifferent threads are reading vs. storing a different driver override.\nAdd locking to avoid the race condition.\n\nThis is in close analogy to commit 6265539776a0 (\"driver core: platform:\nfix race condition with driver_override\") from Adrian Salido.\n\nFixes: 782a985d7af2 (\"PCI: Introduce new device binding path using pci_dev.driver_override\")\nCc: stable@vger.kernel.org\t# v3.16+\nSigned-off-by: Nicolai Stange <nstange@suse.de>\n---\n drivers/pci/pci-sysfs.c | 11 +++++++++--\n 1 file changed, 9 insertions(+), 2 deletions(-)", "diff": "diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c\nindex 1eecfa301f7f..8e075ea2743e 100644\n--- a/drivers/pci/pci-sysfs.c\n+++ b/drivers/pci/pci-sysfs.c\n@@ -686,7 +686,7 @@ static ssize_t driver_override_store(struct device *dev,\n \t\t\t\t const char *buf, size_t count)\n {\n \tstruct pci_dev *pdev = to_pci_dev(dev);\n-\tchar *driver_override, *old = pdev->driver_override, *cp;\n+\tchar *driver_override, *old, *cp;\n \n \t/* We need to keep extra room for a newline */\n \tif (count >= (PAGE_SIZE - 1))\n@@ -700,12 +700,15 @@ static ssize_t driver_override_store(struct device *dev,\n \tif (cp)\n \t\t*cp = '\\0';\n \n+\tdevice_lock(dev);\n+\told = pdev->driver_override;\n \tif (strlen(driver_override)) {\n \t\tpdev->driver_override = driver_override;\n \t} else {\n \t\tkfree(driver_override);\n \t\tpdev->driver_override = NULL;\n \t}\n+\tdevice_unlock(dev);\n \n \tkfree(old);\n \n@@ -716,8 +719,12 @@ static ssize_t driver_override_show(struct device *dev,\n \t\t\t\t struct device_attribute *attr, char *buf)\n {\n \tstruct pci_dev *pdev = to_pci_dev(dev);\n+\tssize_t len;\n \n-\treturn snprintf(buf, PAGE_SIZE, \"%s\\n\", pdev->driver_override);\n+\tdevice_lock(dev);\n+\tlen = snprintf(buf, PAGE_SIZE, \"%s\\n\", pdev->driver_override);\n+\tdevice_unlock(dev);\n+\treturn len;\n }\n static DEVICE_ATTR_RW(driver_override);\n \n", "prefixes": [ "1/3" ] }