From patchwork Fri Oct 12 15:52:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 983157 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42Wsrs4wyRz9s3Z for ; Sat, 13 Oct 2018 02:56:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728884AbeJLX3f (ORCPT ); Fri, 12 Oct 2018 19:29:35 -0400 Received: from mga18.intel.com ([134.134.136.126]:56160 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728786AbeJLX3f (ORCPT ); Fri, 12 Oct 2018 19:29:35 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2018 08:56:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,373,1534834800"; d="scan'208";a="80733831" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.69]) by orsmga007.jf.intel.com with ESMTP; 12 Oct 2018 08:56:27 -0700 From: Keith Busch To: linux-pci@vger.kernel.org, Bjorn Helgaas Cc: Keith Busch , Logan Gunthorpe Subject: [PATCH] PCI/P2PDMA: Fix freeing dev_pagemap on error Date: Fri, 12 Oct 2018 09:52:19 -0600 Message-Id: <20181012155219.15360-1-keith.busch@intel.com> X-Mailer: git-send-email 2.13.6 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The devres_free() API is only to be used after the resource has been unlinked from the device tracking it. Calling this functino directly will hit a kernel BUG_ON. This patch fixes this to use the managed resource release function, devm_kfree(). Fixes: 1380472e7b855 ("PCI/P2PDMA: Support peer-to-peer memory") Cc: Logan Gunthorpe Signed-off-by: Keith Busch Reviewed-by: Logan Gunthorpe --- drivers/pci/p2pdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index da66c7e31730..9c56a10eff15 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -222,7 +222,7 @@ int pci_p2pdma_add_resource(struct pci_dev *pdev, int bar, size_t size, return 0; pgmap_free: - devres_free(pgmap); + devm_kfree(&pci->dev, pgmap); return error; } EXPORT_SYMBOL_GPL(pci_p2pdma_add_resource);