Received: by 10.223.185.116 with SMTP id b49csp648667wrg; Wed, 21 Feb 2018 04:48:11 -0800 (PST) X-Google-Smtp-Source: AH8x226i3ZP0PC6eRREQjbwEqKPBOuufiXr+LCG6I25/5RcOYUGRdbcPq93fHd5Q9wS0rILiTlYi X-Received: by 2002:a17:902:901:: with SMTP id 1-v6mr3091804plm.404.1519217291543; Wed, 21 Feb 2018 04:48:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519217291; cv=none; d=google.com; s=arc-20160816; b=ojnypnU/HWCFjv37uynPJjnbo94JYJ1sdwzxz7UZs0q6mwWinIQJJ0MXCk5u29s5cN WowO+AxX1h/VBrV1qyyCg7GI4Z3jznl2peCLA0g1SmxUgs0/EpRwYzwbuCo3UD6cHpS0 +Lqg3NOn20pUQNxc+Qw6gn+5hrGwR3kebJRDcWxBJGqMbDjgey57GqP+EKqbnQi46LLe cOSpUVwcfsXBigduB3Dme6Vxi0ZqAHIkgaVOFUHZDoqPmQj9THhMCNyNXGQ9bzQEt5aj MBJydfMetieOERupMmeRpWS8MWH6kAe2+aIpgvFmeMjSa99stb6H0HpLay940BX97IHy /PKA== 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 :message-id:date:subject:to:from:dkim-signature :arc-authentication-results; bh=CFYy3bhn7eoWPF6AJMH1sMf+K6u6usD+1M2NOg/UHAw=; b=VtdyXugEOzZm0I0t+YzlUoOWX+xI4UC50ZF9w5gd+zlNTsJMDGtykiwjZujU4FzMiP CdCwQqdlTuB5aY99HtOyBl1jjGz2zo1bGxRwr1aGFE+pbyUN5FFlTntYxZ0AD5wbDP3S 2hn6mDxzugFSJ9+LbDaa8lS4g6RENzaxHTPt7B6paAkbSFSZsBtY9oASno7RvI3ctlfz LCb1gAnhvL5p2H5vpNeIOr9eTQIOqhh7+kmmq7tMky2/aB95az+AaU/dKJQoUTsIY7qT gOTZAdHc4+fZHD2CeP9bX8MTUXy1Yc3fNy7ETbYqoe0+Gl2ke8m9nw84rHTmidoygKrH CwoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YTP6W3WD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2-v6si1258798pli.625.2018.02.21.04.47.57; Wed, 21 Feb 2018 04:48:11 -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=@gmail.com header.s=20161025 header.b=YTP6W3WD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753025AbeBUJHV (ORCPT + 99 others); Wed, 21 Feb 2018 04:07:21 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34728 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752409AbeBUJHR (ORCPT ); Wed, 21 Feb 2018 04:07:17 -0500 Received: by mail-wr0-f196.google.com with SMTP id m5so2297944wrg.1; Wed, 21 Feb 2018 01:07:17 -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=CFYy3bhn7eoWPF6AJMH1sMf+K6u6usD+1M2NOg/UHAw=; b=YTP6W3WDHDARqaf+T4aDY1Z5IM4p2NlgLAJEnVsmJMIqE6PIL/1gIU2w7znKP2BZ2X 7xNMoPQrYm8bHmWr5ZNG5d2ql+zQOCnFE8XKIYCUCz4rYb0umccrvDcSgrGs27/UvIw3 8Tc0WFplVgoOsHMW+k7YF+a3an50Q/gDWwjT/9h/lvzRRZ5H2t5NAaKuuikgQoGSi6Su /FQBXhY8qT6E5TeC2r6XnuyQy73YV1DsUMZ8Ehjy/6tbJhUMsveshHC8/tNh9TbxhWoK fVlGEDVNmR2MHAkDnZFkACakllfB9sE3FlkwEQ0hPDUsUKEgS5RXoNlfc03Y3W7RNFpx XXIw== 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=CFYy3bhn7eoWPF6AJMH1sMf+K6u6usD+1M2NOg/UHAw=; b=ORPK99ZlmTZ3ktjBaeVk3H3JZ/9sR4C8ohoUBdTnadoY6qa/wIhusqOXjEJo+RBS7D YZ6zbHR0iFM2ErnSnEgBUWQMgjsi3uSzTrHz+Fz0JDW02P9/noCHfXfl95yMRR5xLlS4 GeAIZKjHHYNmKK44oYrUYHfhpokK99afmJ0zIlbDjBbuyjsCgGih4s4+/n1IcGQQ91er pc9BUG/AwcAfmRkm6dryBzc3Qk4UA0EulG2iVjZmMlqO0GL1V4w0RjTx37Ym9+gAmMlq oKbLQq/ELtj252qNkRw1bxoE5PLBpfszmAv0kREKzvN7+9LNjYCac3h97xIz7AqQKdFW PiEg== X-Gm-Message-State: APf1xPDny4m9NzXZAkwJRYoao3cmAcW+tMOYiCFlZSovJ31ZZJ21t0qk lHrju+PIF9J/hpFO6iSeSeE= X-Received: by 10.28.167.208 with SMTP id q199mr1530756wme.29.1519204036496; Wed, 21 Feb 2018 01:07:16 -0800 (PST) Received: from baker.fritz.box ([2a02:908:1251:8fc0:d050:cb11:74d7:d8f6]) by smtp.gmail.com with ESMTPSA id x189sm1661875wmg.23.2018.02.21.01.07.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 01:07:16 -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 v2 Date: Wed, 21 Feb 2018 10:07:15 +0100 Message-Id: <20180221090715.2853-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.14.1 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 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. v2: keep printing the info that we try to release the BAR Signed-off-by: Christian König CC: stable@vger.kernel.org --- drivers/pci/setup-res.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index e815111f3f81..c0f091614805 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -402,6 +402,10 @@ void pci_release_resource(struct pci_dev *dev, int resno) struct resource *res = dev->resource + resno; dev_info(&dev->dev, "BAR %d: releasing %pR\n", resno, res); + + if (!res->parent) + return; + release_resource(res); res->end = resource_size(res) - 1; res->start = 0; -- 2.14.1