From patchwork Thu Sep 29 02:13:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 9355551 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6998D6077A for ; Thu, 29 Sep 2016 02:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59CA72978E for ; Thu, 29 Sep 2016 02:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E55B297B3; Thu, 29 Sep 2016 02:14:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2632E297B2 for ; Thu, 29 Sep 2016 02:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753091AbcI2COC (ORCPT ); Wed, 28 Sep 2016 22:14:02 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33660 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753162AbcI2COC (ORCPT ); Wed, 28 Sep 2016 22:14:02 -0400 Received: by mail-pf0-f195.google.com with SMTP id q2so2851100pfj.0 for ; Wed, 28 Sep 2016 19:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ingics-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=WqIOSUCY1ey/OvgPyluuccgCoIEgc+5vtiwKWoSVfFE=; b=Rx63/GOAUNQgwdvCcio47/xOGDwwJ7mK6E92Cn1Wz+1i/trRO79ye9ULg6aeONoEHN BgJ7NNULqAFOUqwZcHlNho7/l7Do7aBgWqHkPtEgMhUtolL5n116n17mSGXCQTc3RCgZ Xd3qEqkqtQinQP4wAQxegyPlcpedawxkAxtKMe2Gzgpt9x0GbusPCEMCqjUTnVWX5mw3 gJ8Wdsirih67qCcCppcD54+qllAaLFX2MNJBQf8695aIgVb8G/ptfyfmRJz2WgqqcS6q 5rTvDxKtnImyJfdcEYji+xUcjeoKicg0N+A5Gexlj6UEgBE1XCgZPQYmy2XJPA0S28o7 NWIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WqIOSUCY1ey/OvgPyluuccgCoIEgc+5vtiwKWoSVfFE=; b=SsOCJnla8qpZjSuhLek50HiLGJW/sRtqDqo6+1YmkyXn9tehVbAuZQv3XqaJ8Zvkji l1ObGzKHhO3Exh354I8TMDnzWznG/3dYM0SSCIpNmg7ID2dhPp7olDu6OnruAEDWm7HN 9utfRcQ4wAjKcxhhVP2qvGf8q2KRo72sWNyLmweWRFEWnrYPO0ljynmLBiFdBRPH04ou wi3GgPKVaRUYsLRFb9+MlB/BqqOPVO6vfeD59jS9KcvconSGSWfq5j1+DdKgnzUakiRw Ex4RnaUH7C+wWgUHmrlWy0UvN3HZ2ufZkU7PPALDvdK79paADhKYvbIrnWJGIGvnS9/k vpJg== X-Gm-Message-State: AE9vXwOf5f7P5nvLHD9g9P+UDU6SJ1jSs6AZCzRLkJ0dAo4r+DftL95Zrc6gYfK8vOLLXw== X-Received: by 10.98.157.199 with SMTP id a68mr62644097pfk.75.1475115241315; Wed, 28 Sep 2016 19:14:01 -0700 (PDT) Received: from localhost.localdomain (36-239-225-60.dynamic-ip.hinet.net. [36.239.225.60]) by smtp.gmail.com with ESMTPSA id i78sm15317846pfj.67.2016.09.28.19.13.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 19:14:00 -0700 (PDT) From: Axel Lin To: "Rafael J . Wysocki" Cc: Chanwoo Choi , MyungJoo Ham , Kyungmin Park , linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Axel Lin Subject: [PATCH v2] PM / devfreq: Add proper locking around list_del() Date: Thu, 29 Sep 2016 10:13:28 +0800 Message-Id: <1475115208-6817-1-git-send-email-axel.lin@ingics.com> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use devfreq_list_lock around list_del() to prevent list corruption. Signed-off-by: Axel Lin Acked-by: MyungJoo Ham --- v2: changes base on MyungJoo's comment. Note, devfreq_list_lock lock region does not to include device_unregister(&devfreq->dev); drivers/devfreq/devfreq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 478006b..66d3c718 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -594,17 +594,19 @@ struct devfreq *devfreq_add_device(struct device *dev, if (devfreq->governor) err = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_START, NULL); - mutex_unlock(&devfreq_list_lock); if (err) { dev_err(dev, "%s: Unable to start governor for the device\n", __func__); goto err_init; } + mutex_unlock(&devfreq_list_lock); return devfreq; err_init: list_del(&devfreq->node); + mutex_unlock(&devfreq_list_lock); + device_unregister(&devfreq->dev); err_out: return ERR_PTR(err);