From patchwork Sun Apr 27 13:28:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 4071581 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 87D799F169 for ; Sun, 27 Apr 2014 13:29:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B13AF2024D for ; Sun, 27 Apr 2014 13:29:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4789C2025A for ; Sun, 27 Apr 2014 13:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751417AbaD0N3K (ORCPT ); Sun, 27 Apr 2014 09:29:10 -0400 Received: from gw-1.arm.linux.org.uk ([78.32.30.217]:53681 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751858AbaD0N3A (ORCPT ); Sun, 27 Apr 2014 09:29:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora; h=Date:Sender:Message-Id:Subject:Cc:To:From:References:In-Reply-To; bh=Xcjyr3VBFMwSPSuFD+slGwUinm4CcEtPe3GYDINnNTQ=; b=MvHdR7+nyglqwuNiRA+kM0L//RYdr3P+lrbl/ReyuN6W64sW7YPve8SY6PXZ1YpaiACk3qnuZ/idoJeu6hDWpYt8z9QUIXjIyA/lTLGRDfXRyp3cJYiseDYKmivtM0qfNTFrcqGsMTvbIxnckSQU8J8W1+bflBhf/bMijeDmCos=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:56402 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1WeP8a-0005iF-EM; Sun, 27 Apr 2014 14:28:56 +0100 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1WeP8Z-0000Uk-Uu; Sun, 27 Apr 2014 14:28:55 +0100 In-Reply-To: <20140427132312.GC26756@n2100.arm.linux.org.uk> References: <20140427132312.GC26756@n2100.arm.linux.org.uk> From: Russell King To: linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Cc: devicetree@vger.kernel.org, linux-pm@vger.kernel.org, Mark Rutland , Pawel Moll , "Rafael J. Wysocki" , Rob Herring Subject: [PATCH 2/5] pm: domains: avoid potential oops in pm_genpd_remove_device() Message-Id: Date: Sun, 27 Apr 2014 14:28:55 +0100 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP pm_genpd_remove_device() should only be called with valid and present pm domain. There are circumstances where we may end up with something that isn't a generic PM domain in dev->pm_domain (eg, vga_switcheroo stuff.) Signed-off-by: Russell King Acked-by: Rafael J. Wysocki --- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index ea91ea0e137b..9d8faecc060c 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1531,7 +1531,7 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd, dev_dbg(dev, "%s()\n", __func__); - if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(dev) + if (!pm_genpd_present(genpd) || IS_ERR_OR_NULL(dev) || IS_ERR_OR_NULL(dev->pm_domain) || pd_to_genpd(dev->pm_domain) != genpd) return -EINVAL;