From patchwork Fri Jan 18 11:42:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konstantin Khlebnikov X-Patchwork-Id: 2001161 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 D9F74DFB77 for ; Fri, 18 Jan 2013 11:43:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755335Ab3ARLmh (ORCPT ); Fri, 18 Jan 2013 06:42:37 -0500 Received: from mail-la0-f50.google.com ([209.85.215.50]:52543 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755250Ab3ARLmf (ORCPT ); Fri, 18 Jan 2013 06:42:35 -0500 Received: by mail-la0-f50.google.com with SMTP id er20so2033459lab.37 for ; Fri, 18 Jan 2013 03:42:32 -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=mcf/9RzwCa7gOSK6QpVqZkFxeQ0ByOodx6FGXWGriAA=; b=uK5KC5xbFLsX52Za3lLrIYN/YAQtMm+akI9uRtEuHK70aLaNU+jSK2LdS0mtAJTcec B+DnBBWbHfKul3BceTSRsaXqoyiGw5SR6ftqg49J//T/+pWbefjMGTrjOa+R/82+MmYq Ve6ev6fuem55cEAkonYODkPeGt9IsRzLTsBKUCUX0eER4Wy57N4CF1GrrX6T/uak2JbQ hYVpVmzEAvaa2/arogRD3NOrswCFmj3jCELH19tmrYFiKq5HBlzXzgDmbN4quSNV3PNE iGj+ODtNGWId51A+xbB5NmPyk0cXibfOoB3lOyNtpZvz4F8fwPlGEzP30YIRxE0d95XW 9mng== X-Received: by 10.152.109.139 with SMTP id hs11mr8244772lab.13.1358509352744; Fri, 18 Jan 2013 03:42:32 -0800 (PST) Received: from localhost (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id fj2sm1986202lbb.6.2013.01.18.03.42.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 18 Jan 2013 03:42:31 -0800 (PST) Subject: [PATCH 5/5] PCI: catch enable-counter underflows To: linux-kernel@vger.kernel.org From: Konstantin Khlebnikov Cc: e1000-devel@lists.sourceforge.net, linux-pci@vger.kernel.org, Bjorn Helgaas Date: Fri, 18 Jan 2013 15:42:30 +0400 Message-ID: <20130118114230.6698.1881.stgit@zurg> In-Reply-To: <20130118113019.6698.25941.stgit@zurg> References: <20130118113019.6698.25941.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 --- 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;