From patchwork Tue Feb 20 08:58:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 10229595 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2106E602B1 for ; Tue, 20 Feb 2018 08:58:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1163123E64 for ; Tue, 20 Feb 2018 08:58:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 049DD26B41; Tue, 20 Feb 2018 08:58:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46A3323E64 for ; Tue, 20 Feb 2018 08:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750781AbeBTI6R (ORCPT ); Tue, 20 Feb 2018 03:58:17 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36290 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750733AbeBTI6Q (ORCPT ); Tue, 20 Feb 2018 03:58:16 -0500 Received: by mail-wr0-f195.google.com with SMTP id u15so12218279wrg.3; Tue, 20 Feb 2018 00:58:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/fJX4OwqnIgf0Qvel0KqduSSUB/v4QMAgwoHeAo3HBI=; b=Pi38tTGloDcXYYG5rPk5LpqAdeBhDe0RB9uP6ax5GWxnfsKvpWVHOpI41ztNKk5Wmu w4yfC+maYP6pMk1v9h6w8EckdVKULdyBRtSLuT0JX8dcYiRHKuLovKf3/yAvMQES+lmV Ofvc7pqM2+ODB1ulbXqhy5xsSO8DlvcxBy1PuLjeJdZ50r4ZX3WTyCXE85pFOQlGHkiH nNrNQirRsRLywep5X1duIaI53XbD57JygWQ5hIxjEpF9sox4FFWoh5gE9cLiB7B9uj7A GxywuPxBLhiADYQYOP1t5pSTdVXb5Nz6ZnTg2sezTrfT/oGXmj/lY2MgUru7xYxn5wJR vffw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=/fJX4OwqnIgf0Qvel0KqduSSUB/v4QMAgwoHeAo3HBI=; b=KW1z6eLpQvioTpLGbTaJHdCyAExsoG8oqTXdygu54GG2CpYnK+TLy5jgpz2LKvjsqL 2ZAOJVdK+n1xc79elFr/Y86y4zZdWfZBMBi8ZCtOO8LUknRhTBJvnvpZqQTIwJIdyJwQ +WMlOoi8ugqbwkJwhpahIAVFREscePl+1iiEMBJ34cZUZ+KHUMn4F4Fo3z+cg9HJGdV5 upYOZiqe30ShkZOottfwHB/2rAqdsgqEtvFT7jmoX+i4rG+q5j24oaDs0W2w2it4HJ4m sQ+0ADSexkwuW6kL6STvnzQ1qdyx8I4Iy/VCO6AWGbZ+YE7qnFjG33yN9NUoh1s1uPbw ol0w== X-Gm-Message-State: APf1xPCwL7PuRgevf/uNs9whTqrhx6D3b21gVhmlql0YqxY+FQ0xJ9po B8aOJ8zC1Mc7q6PYt+S+ba+Wpg== X-Google-Smtp-Source: AH8x224+PvlX7pAuNQwhkVk6K53CBnlMj238SafdtbHM6ZqSafC/Q6QXnkal7iotq6iI37sWTKJ/CQ== X-Received: by 10.223.163.157 with SMTP id l29mr11233558wrb.239.1519117094824; Tue, 20 Feb 2018 00:58:14 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:7008:2819:5c1a:982d]) by smtp.gmail.com with ESMTPSA id x194sm4779844wmd.4.2018.02.20.00.58.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 00:58:14 -0800 (PST) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: bhelgaas@google.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH] PCI: stop crashing in pci_release_resource Date: Tue, 20 Feb 2018 09:58:13 +0100 Message-Id: <20180220085813.1897-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Is it entirely possible that the BIOS wasn't able to assign resources to a device. In this case don't crash in pci_release_resource() when we try to resize the resource. Signed-off-by: Christian König CC: stable@vger.kernel.org --- drivers/pci/setup-res.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index e815111f3f81..fd72c87a9b72 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -401,6 +401,9 @@ void pci_release_resource(struct pci_dev *dev, int resno) { struct resource *res = dev->resource + resno; + if (!res->parent) + return; + dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res); release_resource(res); res->end = resource_size(res) - 1;