From patchwork Mon Feb 4 11:56:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 2091371 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 85D5DDFE82 for ; Mon, 4 Feb 2013 12:15:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754617Ab3BDL4H (ORCPT ); Mon, 4 Feb 2013 06:56:07 -0500 Received: from mail-lb0-f171.google.com ([209.85.217.171]:33441 "EHLO mail-lb0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754587Ab3BDL4G (ORCPT ); Mon, 4 Feb 2013 06:56:06 -0500 Received: by mail-lb0-f171.google.com with SMTP id gg13so6471238lbb.2 for ; Mon, 04 Feb 2013 03:56:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:subject:to:from:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-type :content-transfer-encoding; bh=gYYFMjqYaJEDWkZEpeqk60LFErUv3gghSvNRyzWw4do=; b=QQ/GIRR9Cnwbbe4H83uHzxMgMMgswfLvTimS9ZPk0/Q0LqmmkFKuek5vvHcmvuixez egWyQIFYHA9w7K8b7kXSyb8X5TaGjF7t2vWNXB5S4Ay6c1K5bN7opDjGDNiWef92+ZZU sMlTiVl1oiSNM9oP6cMRV4eQ28hdKt3R0hVunzFAJT15Gd26pmHgcA+WtA9sRz/oQXMq 7608Uoj3oSwAcHcgXSw3e4hrn3t9Hq64h0IKGa+r0Kn8+OLEU51pVakp8AEVIRHm6mbN fYaqY+sQyFMIRwiHjtVfieAw4ru9Hk32vlyCmEzS9ghxGQ0sScBfpgW7Vw/ODQF0PJ8/ v+JA== X-Received: by 10.152.110.18 with SMTP id hw18mr19121852lab.22.1359978964323; Mon, 04 Feb 2013 03:56:04 -0800 (PST) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id fm8sm4187393lbb.17.2013.02.04.03.56.02 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 04 Feb 2013 03:56:03 -0800 (PST) Subject: [PATCH v2 3/7] PCI: catch enable-counter underflows To: e1000-devel@lists.sourceforge.net, linux-pci@vger.kernel.org, "Rafael J. Wysocki" , linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Cc: Bjorn Helgaas Date: Mon, 04 Feb 2013 15:56:01 +0400 Message-ID: <20130204115601.5569.27640.stgit@zurg> In-Reply-To: <20130204115246.5569.85829.stgit@zurg> References: <20130204115246.5569.85829.stgit@zurg> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org This patch adds single WARN_ONCE() check for catching 'enable_cnt' imbalances. Signed-off-by: Konstantin Khlebnikov Cc: linux-pci@vger.kernel.org Cc: Bjorn Helgaas Cc: Rafael J. Wysocki --- drivers/pci/pci.c | 3 +++ 1 file changed, 3 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" 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 5cb5820..ff93f8f 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1401,6 +1401,9 @@ pci_disable_device(struct pci_dev *dev) if (dr) dr->enabled = 0; + dev_WARN_ONCE(&dev->dev, atomic_read(&dev->enable_cnt) <= 0, + "enable counter underflow"); + if (atomic_sub_return(1, &dev->enable_cnt) != 0) return;