From patchwork Thu Mar 12 17:35:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 5997711 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C9F5D9F380 for ; Thu, 12 Mar 2015 17:35:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1333A20379 for ; Thu, 12 Mar 2015 17:35:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2AD332034F for ; Thu, 12 Mar 2015 17:35:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030323AbbCLRft (ORCPT ); Thu, 12 Mar 2015 13:35:49 -0400 Received: from mail-ob0-f170.google.com ([209.85.214.170]:42171 "EHLO mail-ob0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030316AbbCLRfs (ORCPT ); Thu, 12 Mar 2015 13:35:48 -0400 Received: by obbnt9 with SMTP id nt9so15486750obb.9 for ; Thu, 12 Mar 2015 10:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; bh=p4kXfPXcpXROrpUeJ0ly1l1gcmXx0Rz51Kjvk7GVZDY=; b=Up7NMKCMaM6S4ODShTJYwsqaez5gewyXsQb37CKE7lYWCM9cD19Somct06lrpM7CYw gLIziLfZntg7FWJtrXhp1DtRCKNKLQrJ/Cg7g3fsPjKJlREFAJNjsCEnexjJkX/053Y1 DNWSFCYibU79P+YqaKQzqCRXHIYrYt+ajfexs7SFskS/jJkAR4QWNB2I6znyj7kqTMzz eFU3tAdJOVHc4Ccq7TA3rW7ApSV9jrtdaCbsjUj9r7235FYXWNLoD1pPJmntMD9rSRNx cdoie2im3JivwyK0Lkgfzw4lIZsa2oVIQyUhgU4iHKvP41XP6vAkzAb+yPRardPRm+GM Rfdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=p4kXfPXcpXROrpUeJ0ly1l1gcmXx0Rz51Kjvk7GVZDY=; b=T4dvcF8K1PPqueRVKtJvFWiRRqOY/krvcbJO7+Z4BLsxBUaPSq+oRMcj3aORWQBHnp dWCdW705paBKGA/yuLpVP6Gjma3IhNstvP7PVPc/K05yY0UZMNrLGzj7XQ8W5+k5Qw8Y StIk38/uKFt2Agf8GxUlnJol881Hd1SNk2SYIA46Lwg8/9UCOANerxzHqHsHWs/eRfY+ Dox16xwONRdBVam7xucrbyFpw1ehPi5OHRNBme1BUzupoh7cQGwMDvBwU0o25NvDBPjB EZvZ26zY8yP1DfGMw3VU7dZfr5w8xv5lhGrjyymjjCAi5XbubG3uw7PflieuS8gZQvaw wuxQ== X-Gm-Message-State: ALoCoQkWSMeE2eSmMT3OSyA3LO0xBL/0diYv3G0KSnEQWcPMc7oz1GUdiM9WBmuWdN6NYc6xMHoK X-Received: by 10.202.76.207 with SMTP id z198mr9498110oia.56.1426181748204; Thu, 12 Mar 2015 10:35:48 -0700 (PDT) Received: from localhost ([146.7.4.76]) by mx.google.com with ESMTPSA id ut10sm4928474obc.20.2015.03.12.10.35.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 12 Mar 2015 10:35:47 -0700 (PDT) Subject: [PATCH v1 4/4] PCI: Fail pci_ioremap_bar() on unassigned resources To: linux-pci@vger.kernel.org From: Bjorn Helgaas Cc: linux-acpi@vger.kernel.org Date: Thu, 12 Mar 2015 12:35:46 -0500 Message-ID: <20150312173546.1052.76075.stgit@bhelgaas-glaptop2.roam.corp.google.com> In-Reply-To: <20150312173201.1052.28341.stgit@bhelgaas-glaptop2.roam.corp.google.com> References: <20150312173201.1052.28341.stgit@bhelgaas-glaptop2.roam.corp.google.com> User-Agent: StGit/0.16 MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make pci_ioremap_bar() fail if we're trying to map a BAR that hasn't been assigned. Normally pci_enable_device() will fail if a BAR hasn't been assigned, but a driver can successfully call pci_enable_device_io() even if a memory BAR hasn't been assigned. That driver should not be able to use pci_ioremap_bar() to map that unassigned memory BAR. Signed-off-by: Bjorn Helgaas --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a6d191ad9743..28df200bc54c 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -131,7 +131,7 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) /* * Make sure the BAR is actually a memory resource, not an IO resource */ - if (!(res->flags & IORESOURCE_MEM)) { + if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { dev_warn(&pdev->dev, "can't ioremap BAR %d: %pR\n", bar, res); return NULL; }