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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 ED79EC4332B for ; Fri, 20 Mar 2020 00:26:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C296520714 for ; Fri, 20 Mar 2020 00:26:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hIL879rr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbgCTA0r (ORCPT ); Thu, 19 Mar 2020 20:26:47 -0400 Received: from mail-pj1-f67.google.com ([209.85.216.67]:38998 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgCTA0r (ORCPT ); Thu, 19 Mar 2020 20:26:47 -0400 Received: by mail-pj1-f67.google.com with SMTP id ck23so1725504pjb.4 for ; Thu, 19 Mar 2020 17:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3CquBIknUh+wWij7pI3+EpiDVMbP4UE5jsk6gx0/y4s=; b=hIL879rr/L5dDRaQ5wFuNONmj14fKu2pOrCX0vcpiDCbDvQNW9D0XNhjQ812YIdJcl RFAA2QzyjMzwd4GerjIE1pcQTu7olaNibdMLiloj/OvyJs0dipLnlGDvPoaPJN07LF7F UpfdW8IHurtcqD7j9uunVEbKf7ka1RrgzG9H7++qEoXG0xofRl0tYeR5MQrxj+lu36Tf FZ+3j94YLwPxT4dCVO4muAjKHWNj39N/pscVLolXnbkt+oFHux9FDZk0ms266R6Y9OMV HjGdlLmJ9rmc+0SDvkMngNObYsKNqMJupbmJJiQ14SRp5BiLmdkQnqDHTRwXie3QkLi/ ctIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3CquBIknUh+wWij7pI3+EpiDVMbP4UE5jsk6gx0/y4s=; b=dBLRJNfJIcBf4jf1MyOEdEJjHhVWkpyZHOHQa+z/E00GoV9qMBHC7mcCNk1I2rMtDM B3rtRMyAM+d3NZL4pG2hxXQnxbAhaB+7Mzv9G1xi0by5o/HQ+PqwnrKdzdOfrJPnCtko DVhgoQwYOnPydaSjNOuoDtDfjsJyacMbYqC9Y2fYYTXfvMdIsYQIzp+HSqBJv8O1yXOm LkRl6m1+9Y1xy31I3vyQqcTN9a6WWpAFei0L+eJFLmXUJ2WgMW+tkkeDJmvFNb2sVt1G xO5DaRHXesS67JnrNn1jgFRkFuo5f23u0fNS6qZfiafYz/5oYeLx2dO33rueERXuEJCF osQw== X-Gm-Message-State: ANhLgQ0okQ1OUIVm526zRwjY5OMwxdWm9Dpp+4EaWpCe4VgC4X+tbZmi /nEnlLPcsudOe6JdtgvK1OXSXQ== X-Google-Smtp-Source: ADFU+vuvvlwjzHruspaJwITkonWxQdZ8Jw5QJj79hDHHYrQ1qrBu8aOfup37D42mz/zOwumlweKbcw== X-Received: by 2002:a17:90a:3328:: with SMTP id m37mr6559226pjb.158.1584664004002; Thu, 19 Mar 2020 17:26:44 -0700 (PDT) Received: from yoga (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id z125sm3629586pfz.187.2020.03.19.17.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2020 17:26:43 -0700 (PDT) Date: Thu, 19 Mar 2020 17:26:40 -0700 From: Bjorn Andersson To: Mike Tipton Cc: georgi.djakov@linaro.org, agross@kernel.org, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] interconnect: qcom: Fix uninitialized tcs_cmd::wait Message-ID: <20200320002640.GC458947@yoga> References: <20200319231021.18108-1-mdtipton@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200319231021.18108-1-mdtipton@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 19 Mar 16:10 PDT 2020, Mike Tipton wrote: > Currently, if tcs_cmd_gen is called with commit=false, then > tcs_cmd::wait is left uninitialized. Since the tcs_cmd structures passed > to this function aren't zero-initialized, then we're left with random > wait values. This results in waiting for completion for more commands > than is necessary, depending on what's on the stack at the time. > > Removing the unnecessary if-condition fixes this, but add an explicit > memset of the tcs_cmd structure as well to ensure predictable behavior > if more tcs_cmd members are added in the future. > > Fixes: 976daac4a1c5 ("interconnect: qcom: Consolidate interconnect RPMh support") > Signed-off-by: Mike Tipton Reviewed-by: Bjorn Andersson Regards, Bjorn > --- > drivers/interconnect/qcom/bcm-voter.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/interconnect/qcom/bcm-voter.c b/drivers/interconnect/qcom/bcm-voter.c > index 2adfde8cdf19..2a11a63e7217 100644 > --- a/drivers/interconnect/qcom/bcm-voter.c > +++ b/drivers/interconnect/qcom/bcm-voter.c > @@ -96,6 +96,8 @@ static inline void tcs_cmd_gen(struct tcs_cmd *cmd, u64 vote_x, u64 vote_y, > if (!cmd) > return; > > + memset(cmd, 0, sizeof(*cmd)); > + > if (vote_x == 0 && vote_y == 0) > valid = false; > > @@ -112,8 +114,7 @@ static inline void tcs_cmd_gen(struct tcs_cmd *cmd, u64 vote_x, u64 vote_y, > * Set the wait for completion flag on command that need to be completed > * before the next command. > */ > - if (commit) > - cmd->wait = true; > + cmd->wait = commit; > } > > static void tcs_list_gen(struct list_head *bcm_list, int bucket, > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, > a Linux Foundation Collaborative Project