From patchwork Sat Feb 14 15:27:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King X-Patchwork-Id: 5828671 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 57D489F380 for ; Sat, 14 Feb 2015 15:27:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93B44201BC for ; Sat, 14 Feb 2015 15:27:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B12C22021F for ; Sat, 14 Feb 2015 15:27:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753818AbbBNP1u (ORCPT ); Sat, 14 Feb 2015 10:27:50 -0500 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:41059 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752743AbbBNP1t (ORCPT ); Sat, 14 Feb 2015 10:27:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Date:Sender:Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References:In-Reply-To; bh=/bWFTOYzEU4Q+JZkDvV/4W9GqkTY5EbpXhkYVBgQD98=; b=jGR5W9P+7z895iaxL/n5sI6c+a4esIUb0BydAubWp2PG6QCLvztEvTzh0p+dmGBleECtjtIEboLOQKn5EEHuFkf+ESfGKVCtPSBO+i50aaWQrT+8BYvZ806cMRfxMWzeAXnt+hGGNVYwHQ6jTXlD2AqRa+m1VS3FWQd15TNJHjQ=; Received: from e0022681537dd.dyn.arm.linux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:34126 helo=rmk-PC.arm.linux.org.uk) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1YMedA-0007hh-Sl; Sat, 14 Feb 2015 15:27:41 +0000 Received: from rmk by rmk-PC.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1YMed5-00054V-QK; Sat, 14 Feb 2015 15:27:35 +0000 In-Reply-To: <20150214152659.GI8656@n2100.arm.linux.org.uk> References: <20150214152659.GI8656@n2100.arm.linux.org.uk> From: Russell King To: Andrew Lunn , Jason Cooper , "Rafael J. Wysocki" , Sebastian Hesselbarth Cc: Len Brown , Greg Kroah-Hartman , linux-pm@vger.kernel.org Subject: [PATCH 2/8] pm: domains: avoid potential oops in pm_genpd_remove_device() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Sat, 14 Feb 2015 15:27:35 +0000 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,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.) Acked-by: Rafael J. Wysocki Signed-off-by: Russell King --- 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 b3fbc21da2dc..11a1023fa64a 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c @@ -1509,7 +1509,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;