From patchwork Sat May 29 11:05:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Geis X-Patchwork-Id: 12287887 X-Patchwork-Delegate: kuba@kernel.org 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 3E7EBC4708E for ; Sat, 29 May 2021 11:06:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AE3061284 for ; Sat, 29 May 2021 11:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbhE2LHo (ORCPT ); Sat, 29 May 2021 07:07:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229805AbhE2LHm (ORCPT ); Sat, 29 May 2021 07:07:42 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC586C061574; Sat, 29 May 2021 04:06:04 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id ee9so3209328qvb.8; Sat, 29 May 2021 04:06:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BHAPU9WEhe/IzLMZhMUy9J1dZ6fQXj5w6gD2AFHDUxk=; b=GBm7RPfWVL3eiOLiCALVzFus8WA+qOh/0NGG59feXfnTC8IihmgwDkejiku2/35vBG IkNGXfnSqTXcI15tfdTYO+MAx4MuRSUL/fP0sEdK/teIkjr1vGJZ5ZqyelNt9bWKB139 SuF8t18QTQeto+BptnZm+Qe7jM55ZB0M1T/fOcwan+E1byy9dVeUZJJSLQpqi9ux/Hb7 BQWwrxpujhcqPEbFbn0xWypECXGbV1ZnPmGzmlBrbGSDb4drIhvDGhYIatc0pYnNkrhJ X0kTD4TRYHQM00aImlwKYy7vT53dAezD4NUCq4fjEJQhwldgsDCMI70Bk3pfPNtJIt7/ t+vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BHAPU9WEhe/IzLMZhMUy9J1dZ6fQXj5w6gD2AFHDUxk=; b=DgPzJTCx/LX75oBJ2WqXXtMLVckzOMxxXwbtoImwIwR3hYmUGCIQ+CTfVFxK/ngM2k QwlZTARStxajz1/9HsFA1qKQ4RMDVI5rMwd9OpCSLcQTgb+WH5fPotjRjkSMYwO/c2Lt jPkXXYZxsw69/ou4P24VoSLx1BVV6+9slMxlN/HJWpO6RN78/x8UgkowtkxVOxjw0iHx kcOKElMUvKe9mBxHsVLoXeqaSh1EOYYEc/HW2I8eAjdAmUkshlLed3oBYVg7tPSeFIjR Mo9ai9ms5GzcaUk0Dpc2G1jDG8b5Rb9cCFT7BHFv9wdfeXaxFOzDLj2XGL7+c9GzTPV7 rA8Q== X-Gm-Message-State: AOAM533R90sPyGdLBnL3QPhF/jTr8mJySR+TSe8yi7xG0PskQ2jCdHNU I5yaCmsL3PyeE1hLHcDEBbaXhLUPrwInzqpK X-Google-Smtp-Source: ABdhPJwS4lSQgX/7PoX4A8kBZicr2rpGO3qLlEm64wPaCqyO2U94yreiItA/phAku0pF/Av19qrFBg== X-Received: by 2002:a0c:e40e:: with SMTP id o14mr8188188qvl.30.1622286364041; Sat, 29 May 2021 04:06:04 -0700 (PDT) Received: from master-laptop.sparksnet ([2601:153:980:85b1:5af:2aab:d2d5:7c9a]) by smtp.gmail.com with ESMTPSA id t137sm5328991qke.50.2021.05.29.04.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 May 2021 04:06:03 -0700 (PDT) From: Peter Geis To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Nathan Chancellor Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Peter Geis , kernel test robot Subject: [PATCH v3 1/2] net: phy: fix yt8511 clang uninitialized variable warning Date: Sat, 29 May 2021 07:05:55 -0400 Message-Id: <20210529110556.202531-2-pgwipeout@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210529110556.202531-1-pgwipeout@gmail.com> References: <20210529110556.202531-1-pgwipeout@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org clang doesn't preinitialize variables. If phy_select_page failed and returned an error, phy_restore_page would be called with `ret` being uninitialized. Even though phy_restore_page won't use `ret` in this scenario, initialize `ret` to silence the warning. Fixes: 48e8c6f1612b ("net: phy: add driver for Motorcomm yt8511 phy") Reported-by: kernel test robot Reviewed-by: Andrew Lunn Signed-off-by: Peter Geis --- drivers/net/phy/motorcomm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index 796b68f4b499..68cd19540c67 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -50,8 +50,8 @@ static int yt8511_write_page(struct phy_device *phydev, int page) static int yt8511_config_init(struct phy_device *phydev) { + int oldpage, ret = 0; unsigned int ge, fe; - int ret, oldpage; /* set clock mode to 125mhz */ oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE); From patchwork Sat May 29 11:05:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Geis X-Patchwork-Id: 12287889 X-Patchwork-Delegate: kuba@kernel.org 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 4BF9FC4708F for ; Sat, 29 May 2021 11:06:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C8C7611AB for ; Sat, 29 May 2021 11:06:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbhE2LHp (ORCPT ); Sat, 29 May 2021 07:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbhE2LHn (ORCPT ); Sat, 29 May 2021 07:07:43 -0400 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 965A3C06174A; Sat, 29 May 2021 04:06:05 -0700 (PDT) Received: by mail-qk1-x72a.google.com with SMTP id j189so6698592qkf.2; Sat, 29 May 2021 04:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qK+54IGHwuQkuGGrspkW6kXX3D+Ib9Q7t9lsF0kQMyQ=; b=N5ZoH3ULZijvt18nW7ax/7Ymz5v/qI0st36qfH12OkhQO8znRG6J44m9CwaA7PK5Oz bTDkvEWYCbqGoNu6PTqwBGdad7eD/nt+/dYew5SGsiqD3K5vLdUlpqzbQdlpTJNGJ9zO p7XnkPkCPygxM7egcSM9vOE2a3SR5CGA8M8uu0/Gq1UaW7xEDOEYa35QU1gVrpZEFInC ieI8RqCf2/V9pvJ4dYW4cEMmfQTl769hBePBj+ST22vOTjLMe+uQiet05gPRRXLccm/4 QVfCxl72mhE8Ilpl7hZAkhWc+6MbdvWg9yrUoF6KoaVD6oYk23OLicod848RxmbjUedz ZUEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qK+54IGHwuQkuGGrspkW6kXX3D+Ib9Q7t9lsF0kQMyQ=; b=cMWhthKI6UJ1h2nkJ1W9wPJgiQhGyGhpjvq7ZEkHzRJhauZVqtXWkBWKHrDRqWhH7a MTQQljEDUERqTZj4MqREoTxjVGnnty2zMvO8W8pPxenyJbO9Svt6pFgK+1CFuFx77ibd 7dzGC6TU5wHeak7cj0hL5sd3irtAplXBgcaAMJkvsjRXFJRLHQMABiwbCyM94Z73tJSd qVxbaYh4JLvEIxEqx/0ehAMAF/FDm5yPdAMb1oV2WCtW0LT0VDzJfG+3p17aVyfMVnNj AzCdY51hUixKfBpprTV632LAhfzLFzpf2JiaSe4hEYzDEOifZbRE9z3sD8qNH+bL4zkY t+hA== X-Gm-Message-State: AOAM530HfIa2oLssocg1pLgWftrhUJ3ky5YJv3TpmrziV1nO3X1kdEjo BGBjrJ9Ek3ZMvvM/2JV/m0s= X-Google-Smtp-Source: ABdhPJxgYZDIbmcWTRHBDPQ7pKykzh9RKix8mwhJ6k8mPoqMlxKt5zEJNy8Rlti04jgVT/kC0HAi6Q== X-Received: by 2002:a37:5d46:: with SMTP id r67mr7738243qkb.72.1622286364728; Sat, 29 May 2021 04:06:04 -0700 (PDT) Received: from master-laptop.sparksnet ([2601:153:980:85b1:5af:2aab:d2d5:7c9a]) by smtp.gmail.com with ESMTPSA id t137sm5328991qke.50.2021.05.29.04.06.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 May 2021 04:06:04 -0700 (PDT) From: Peter Geis To: Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Nathan Chancellor Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Peter Geis , kernel test robot Subject: [PATCH v3 2/2] net: phy: abort loading yt8511 driver in unsupported modes Date: Sat, 29 May 2021 07:05:56 -0400 Message-Id: <20210529110556.202531-3-pgwipeout@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210529110556.202531-1-pgwipeout@gmail.com> References: <20210529110556.202531-1-pgwipeout@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org While investigating the clang `ge` uninitialized variable report, it was discovered the default switch would have unintended consequences. Due to the switch to __phy_modify, the driver would modify the ID values in the default scenario. Fix this by promoting the interface mode switch and aborting when the mode is not a supported RGMII mode. This prevents the `ge` and `fe` variables from ever being used uninitialized. Fixes: 48e8c6f1612b ("net: phy: add driver for Motorcomm yt8511 phy") Reported-by: kernel test robot Reviewed-by: Andrew Lunn Signed-off-by: Peter Geis --- drivers/net/phy/motorcomm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c index 68cd19540c67..7e6ac2c5e27e 100644 --- a/drivers/net/phy/motorcomm.c +++ b/drivers/net/phy/motorcomm.c @@ -53,15 +53,10 @@ static int yt8511_config_init(struct phy_device *phydev) int oldpage, ret = 0; unsigned int ge, fe; - /* set clock mode to 125mhz */ oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE); if (oldpage < 0) goto err_restore_page; - ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M); - if (ret < 0) - goto err_restore_page; - /* set rgmii delay mode */ switch (phydev->interface) { case PHY_INTERFACE_MODE_RGMII: @@ -80,14 +75,20 @@ static int yt8511_config_init(struct phy_device *phydev) ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN; fe = YT8511_DELAY_FE_TX_EN; break; - default: /* leave everything alone in other modes */ - break; + default: /* do not support other modes */ + ret = -EOPNOTSUPP; + goto err_restore_page; } ret = __phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge); if (ret < 0) goto err_restore_page; + /* set clock mode to 125mhz */ + ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M); + if (ret < 0) + goto err_restore_page; + /* fast ethernet delay is in a separate page */ ret = __phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE); if (ret < 0)