From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6910EC64E7B for ; Wed, 2 Dec 2020 17:20:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1427C22248 for ; Wed, 2 Dec 2020 17:20:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730803AbgLBRU0 (ORCPT ); Wed, 2 Dec 2020 12:20:26 -0500 Received: from foss.arm.com ([217.140.110.172]:45556 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728815AbgLBRU0 (ORCPT ); Wed, 2 Dec 2020 12:20:26 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 53A021FB; Wed, 2 Dec 2020 09:19:39 -0800 (PST) Received: from [10.57.31.176] (unknown [10.57.31.176]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E905E3F575; Wed, 2 Dec 2020 09:19:36 -0800 (PST) Subject: Re: [PATCH v4 3/4] powercap/drivers/dtpm: Add API for dynamic thermal power management From: Lukasz Luba To: Daniel Lezcano Cc: rjw@rjwysocki.net, ulf.hansson@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Thara Gopinath , Lina Iyer , Ram Chandrasekar , Zhang Rui , Arnd Bergmann , "open list:GENERIC INCLUDE/ASM HEADER FILES" References: <20201201192801.27607-1-daniel.lezcano@linaro.org> <20201201192801.27607-4-daniel.lezcano@linaro.org> <9db21e5e-ede0-87c3-a556-8a5e666d52bc@arm.com> Message-ID: Date: Wed, 2 Dec 2020 17:19:35 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <9db21e5e-ede0-87c3-a556-8a5e666d52bc@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/2/20 12:37 PM, Lukasz Luba wrote: > Hi Daniel, > > I realized small issue when I went through this new mutex code > (which is safer IMHO). > > On 12/1/20 7:28 PM, Daniel Lezcano wrote: > > [snip] > >> +int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm >> *parent) >> +{ >> +    struct powercap_zone *pcz; >> + >> +    if (!pct) >> +        return -EAGAIN; >> + >> +    if (root && !parent) >> +        return -EBUSY; >> + >> +    if (!root && parent) >> +        return -EINVAL; >> + >> +    if (parent && parent->ops) >> +        return -EINVAL; >> + > > Maybe it worth to add a check of dtpm pointer here, just to play safe? > >     if (!dtpm) >         return -EINVAL; > > The dtpm->ops might explode when we don't capture this miss-usage during > reviews of future drivers/shim layers. What do you think? > > >> +    if (dtpm->ops && !(dtpm->ops->set_power_uw && >> +               dtpm->ops->get_power_uw && >> +               dtpm->ops->release)) >> +        return -EINVAL; >> + > > I am going to stress test the whole series with hotplug today > and add review for patch 4/4. > I have tested with a hotplug stress and looks OK with the mutex. You can add again the tag: Tested-by: Lukasz Luba Regards, Lukasz