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: 9355549 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 9AFB46077A for ; Thu, 29 Sep 2016 02:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B4C52978E for ; Thu, 29 Sep 2016 02:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7F64D297B5; Thu, 29 Sep 2016 02:14:04 +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 026592978E for ; Thu, 29 Sep 2016 02:14:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753639AbcI2COC (ORCPT ); Wed, 28 Sep 2016 22:14:02 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:34419 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753091AbcI2COC (ORCPT ); Wed, 28 Sep 2016 22:14:02 -0400 Received: by mail-pf0-f193.google.com with SMTP id 21so2862125pfy.1 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=Cm4AQkQgFMwzNY16GhznH2DnDf5WxntMetg+Q2pBmx96Nir9FItyfw8wPHISsxoYga myyKlxtf8Z14F6BxfI5Q4XX2dgMhDMrA9ZJXM72k0ZvQy6/gZAvV7+NTcHKPUitmQ6+o DWFYWvq6iXBuFZPO6TPMkHZ395jpkUVtaYSxlCLeOGtbrXacsho1Pt/c6Mc+joFbesN0 9+TZtV6Oy1n0cps9B1VoIUpHhE+U+DyvZGEZJHk8HdNB15uC3f3ph376IdEa6ewbqX95 aaDsP7M70Bpb+p6GIWffc+CH4dm9hpRYteAX8eXE+hXRSv6pDDE8CEJUbDQis/qF7RlN E9Cw== X-Gm-Message-State: AE9vXwOAhfYLdXnR///PnxMcFCZfNTu03WHCcqb80OvGo19axBtv3ro5EXUWu1QqfxgZ0A== 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-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@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);