Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1142449imm; Tue, 3 Jul 2018 06:18:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLMlVp9f0w703Nw801yA5cdO6z8txuftQ3lnlderkiVHQVKckYXI/Skurs55XELu7bsi4Si X-Received: by 2002:a17:902:b28c:: with SMTP id u12-v6mr29517185plr.16.1530623908253; Tue, 03 Jul 2018 06:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530623908; cv=none; d=google.com; s=arc-20160816; b=iDAliwDYpOcdgFrkip0aJ7E6p7CVcF/iA7UpAt8/RcLeDzs7dJbQ0lYjsHwkrHSYLn Y5xziuovPQb5Aq0f7WFOn2mGMwbQyHxYsZB+a3wrjzN3gPf7c9pPXMDP9rkXH039bPhx DlFzeRz0erYzAXV0BSVt4ISW9ikvFiQX93SKRgCR9WMnvEU8bhrLp+m/892ogvKMm3l0 56BC4VBqgL83AE1u7YJv9Y5p7BUVExYwkqCUTnj5nYkUd58LK0aQNM2gl41ZQkogPn8+ Mij2yaHlKxwvwsNeHNd6pa++L9qKKAxw0mHpqYWYAwT0EqaTh0D1Tiqx3WSEVvRXt0bJ DMJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=H1iVx0AbqGmxYEFsv3fcM33eFKZr7TsE4bnBWlFCJv0=; b=RL8xuUI+cZSI9KxX24GM33IGGPola1HHvjCamK5M8ZIZlFrNMkIpXeZkjUlC16uf3v YooFGuA+np/Wz8eNagmN/MJzxUw+/w1xbqS1OHDoAw7z5gQ2Ga8KOt0GBb0CKsRQ7Eal Ui7BuB1v5pbrkqoB2RdmkRYymzkRNr7utOC+jU+nGEanjSjj3z9rx6XeniVeP9gN7ouo TC2CCxDK5+G9nARBwYOGLfKeI6TxGY/+R6oPSk/iqZMM14z3yXhVKTmJzs/phcSM7Qj2 FEAvoAU0vjgasODCx9SCo76sM9oJX20VmevhxA+gmdso+Lquwle/1WQpBZNv+YIWPyg6 hvNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12-v6si1066072pll.461.2018.07.03.06.17.57; Tue, 03 Jul 2018 06:18:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753272AbeGCNQl (ORCPT + 99 others); Tue, 3 Jul 2018 09:16:41 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:60416 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbeGCNQk (ORCPT ); Tue, 3 Jul 2018 09:16:40 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 066B4260185 Subject: Re: [PATCH v3] PM / devfreq: Fix devfreq_add_device() when drivers are built as modules. To: myungjoo.ham@samsung.com, "linux-kernel@vger.kernel.org" Cc: "kernel@collabora.com" , Chanwoo Choi , Kyungmin Park , "linux-pm@vger.kernel.org" References: <20180621220430.25644-1-enric.balletbo@collabora.com> <20180703105723epcms1p63bd7b3cf49722b204d7ca0dfd98d5d15@epcms1p6> From: Enric Balletbo i Serra Message-ID: <60b611ac-69e0-1339-599a-299483b6df3d@collabora.com> Date: Tue, 3 Jul 2018 15:16:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180703105723epcms1p63bd7b3cf49722b204d7ca0dfd98d5d15@epcms1p6> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi MyungJoo On 03/07/18 12:57, MyungJoo Ham wrote: >> @@ -988,12 +1030,13 @@ static ssize_t governor_store(struct device *dev, struct device_attribute *attr, >> if (ret != 1) >> return -EINVAL; >> >> - mutex_lock(&devfreq_list_lock); >> - governor = find_devfreq_governor(str_governor); >> + governor = try_then_request_governor(str_governor); >> if (IS_ERR(governor)) { >> - ret = PTR_ERR(governor); >> - goto out; >> + return PTR_ERR(governor); >> } >> + >> + mutex_lock(&devfreq_list_lock); >> + >> if (df->governor == governor) { >> ret = 0; >> goto out; >> -- > > The possibility that the result of try_then_request_governor is > not kept protected until the line of > "if (df->governor == governor)" is itching. > > Can you make it kept "locked" from the return of > find_devfreq_governor() (either in try_then... or in this function) > to the unlock of governor_store()? > Sure, I'll send v4 in a minute. Thanks, Enric > > Cheers, > MyungJoo >