Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp478778rwe; Fri, 14 Apr 2023 05:57:29 -0700 (PDT) X-Google-Smtp-Source: AKy350bxYhaahK5V1s/yp5hf8ps6R4yiU0zbtefrXlpKXxHR6526ViokcKKJsQpd2LGEENpK2bpK X-Received: by 2002:a17:90b:4018:b0:247:1e30:5880 with SMTP id ie24-20020a17090b401800b002471e305880mr5358741pjb.38.1681477049687; Fri, 14 Apr 2023 05:57:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681477049; cv=none; d=google.com; s=arc-20160816; b=uwIlUdHb+oi1WPOIu9ika0Mqfd2VbNmNxDfmjMtkeBGr9BhpbzA7qRbwkNn7STF5Gw UZRhU8LDHWbLAokrtrKGoRQSZSNVg+OMhWqLD6RA/VrbeRVbOcis+Gu2n+wtBnMPeFDt MGAiY5NbvEwA89WlIQWsvRsb+a2Kdt6SkkjcYn79l74n8SWXQqegzG2xPmmHAij5uLVj 3cqFpxHufsdlcbEoiV+7flc2rygoLnJe93ieIjs6FSRkoXF/wcKb3E348SqBCn32pTaN 40j1CcAVc2f0mbbjS0yb2nlwZjoRbK5X1g7Y4HQMHMtOzlWw1tA8PTSnr54tCGI8vmVb uZvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:mime-version :in-reply-to:references:user-agent:from:dkim-signature; bh=c1mRBvmkKWpgvM1gONebrVKM3TA+ePdq5Jwjyb83ndI=; b=hybGhZPAa0794h+r08PLJx7Wyxzz+v0MbswkJQvvGtaSUe4O4gl83yj0ku69jJ1E3f n9YB2+SNwDhorMDhWVs4aEW4bp8ZGFxIQBrv5tUxP4x5c77rrnWtGxhjo3fR2adGjAEp 2+YMixWQd4JWpWEW745MP2xMGXaafqdGFBx9/wtH8fTm9SIzB17fKQCjSfExN113xLNF W0QBMyPp95nehX9IxqxLLhwXe8hPDg7f7jrNfsZMqjLmZkTfqf9nloFs8vvd030iCkYY BFcVDD4LNlvfSDJzCyC9QiJocxZh9JdEP/umdngWhMkzEOJlkDqzErnhW9N8FRUOTlIK i9Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=hfxcYBA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a63f306000000b0050f975790dcsi4756989pgh.464.2023.04.14.05.57.18; Fri, 14 Apr 2023 05:57:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20221208.gappssmtp.com header.s=20221208 header.b=hfxcYBA6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230108AbjDNMxE (ORCPT + 99 others); Fri, 14 Apr 2023 08:53:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbjDNMxC (ORCPT ); Fri, 14 Apr 2023 08:53:02 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F5806A6B for ; Fri, 14 Apr 2023 05:52:58 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id mb2so1610548qvb.10 for ; Fri, 14 Apr 2023 05:52:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681476777; x=1684068777; h=cc:to:subject:message-id:date:mime-version:in-reply-to:references :user-agent:from:from:to:cc:subject:date:message-id:reply-to; bh=c1mRBvmkKWpgvM1gONebrVKM3TA+ePdq5Jwjyb83ndI=; b=hfxcYBA6wKz0ja41R5GILX3KMG8FLrGhi8JWeM0W+y08tHIeAr1vzeBz6MD4JxzdBF QIhHkA3pbw59fZMAbr6b0i7r250bHgCCQTtKAKttdlfD8JhZyvUmQNuAj/uhdZtlKR7B KH05LZDkOItVIJbkhdHUcPbhGF37Iuzi2x+KKmUQGbaXez7ZikZDtNYtH6a64wNFe3lT DhyEQk8l44mdyq2Y4kI730hkh110qFH4d7oMA7EiD2VeMU9FLouu/qguZi9jRdHRRWaw +3u1tDfvw2LIjhSEsl0CC8jA7Lp6j743ttLMCvJJ42APWUvnVVahAUfe6mF3GO9ThAtK ehnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681476777; x=1684068777; h=cc:to:subject:message-id:date:mime-version:in-reply-to:references :user-agent:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c1mRBvmkKWpgvM1gONebrVKM3TA+ePdq5Jwjyb83ndI=; b=OoDVnY4lZ+ZhFXvEXxYSuRAYzxjPvj9ygrEVXjzNgS4Mr5cONRmGy4PbdfYmU3trLM KbaGpQfNqqN4vv/6Cdug8WlFI09EU8DbBk2XamNdGEXA+HNDbAdjxX7OHIRE22yg1R7m 946rS4/YLUT/sxaYLaoA0DtdJPSMidpThlsjfGZ9vDPXSbuTa4pjS5ToSnehACrQajtu xJdBijVYzfjTF77G7wAW4oYn+DFZyC4LjlWl6lgjQLOixf0N4F0qzqjwPknU69v7uKRC tqsL7qmRieFIPRNE9luCB/fcytL5V6E49PN+cplZvhZtvkTwpeKeNjghG6fLz6fxK4dp tC/w== X-Gm-Message-State: AAQBX9e3PVSuzMciDJiL91rotMZg/Ia8K86aFi79Uid2KpN8Chg350LX GwymCDec39D0XNYOUfo5ENgd6j33XDrvJFqosTACZx/uqxhioAFQ X-Received: by 2002:a05:6214:2504:b0:56f:728:19d4 with SMTP id gf4-20020a056214250400b0056f072819d4mr3900460qvb.26.1681476777521; Fri, 14 Apr 2023 05:52:57 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Fri, 14 Apr 2023 05:52:57 -0700 From: Guillaume Ranquet User-Agent: meli 0.7.2 References: <20230413-fixes-for-mt8195-hdmi-phy-v1-0-b8482458df0d@baylibre.com> <20230413-fixes-for-mt8195-hdmi-phy-v1-1-b8482458df0d@baylibre.com> In-Reply-To: MIME-Version: 1.0 Date: Fri, 14 Apr 2023 05:52:57 -0700 Message-ID: Subject: Re: [PATCH 1/2] phy: mediatek: hdmi: mt8195: fix uninitialized variable usage in pll_calc To: AngeloGioacchino Del Regno , Matthias Brugger , Chun-Kuang Hu , Philipp Zabel , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I Cc: dri-devel@lists.freedesktop.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, kernel test robot Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Apr 2023 12:31, AngeloGioacchino Del Regno wrote: >Il 13/04/23 14:46, Guillaume Ranquet ha scritto: >> The ret variable in mtk_hdmi_pll_calc() was used unitialized as reported >> by the kernel test robot. >> >> Fix the issue by removing the variable altogether and testing out the >> return value of mtk_hdmi_pll_set_hw() >> >> Fixes: 45810d486bb44 ("phy: mediatek: add support for phy-mtk-hdmi-mt8195") >> Reported-by: kernel test robot >> Signed-off-by: Guillaume Ranquet >> --- >> drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 7 +++---- >> 1 file changed, 3 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c >> index abfc077fb0a8..e10da6c4147e 100644 >> --- a/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c >> +++ b/drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c >> @@ -213,7 +213,7 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, >> u64 tmds_clk, pixel_clk, da_hdmitx21_ref_ck, ns_hdmipll_ck, pcw; >> u8 txpredivs[4] = { 2, 4, 6, 12 }; >> u32 fbkdiv_low; >> - int i, ret; >> + int i; >> >> pixel_clk = rate; >> tmds_clk = pixel_clk; >> @@ -292,10 +292,9 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, >> if (!(digital_div <= 32 && digital_div >= 1)) >> return -EINVAL; >> >> - mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, >> + if (mtk_hdmi_pll_set_hw(hw, PLL_PREDIV, fbkdiv_high, fbkdiv_low, >> PLL_FBKDIV_HS3, posdiv1, posdiv2, txprediv, >> - txposdiv, digital_div); >> - if (ret) >> + txposdiv, digital_div)) >> return -EINVAL; >> > >I don't get why we're returning -EINVAL unconditionally in the first place, here. > >Function mtk_hdmi_pll_set_hw() should return zero or a negative error number: in >that case, the previous *intention* was fine, so this should be > Hi Angelo, I was maybe a bit too quick on fixing this that way. Anyway it doesn't change a thing as mtk_hdmi_pll_set_hw() eitheir returns 0 or -EINVAL. But I agree that the logic is dubious and propagating the return value is the right thing to do. I see that Arnd and Tom posted versions that you might prefer: https://lore.kernel.org/linux-phy/20230414075842.4006164-1-arnd@kernel.org/ https://lore.kernel.org/linux-phy/20230414122253.3171524-1-trix@redhat.com/ Thx, Guillaume. > ret = mtk_hdmi_pll_set_hw(....) > if (ret) > return ret; > > return 0; > > >Regards, >Angelo