Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp5539601rwb; Tue, 17 Jan 2023 15:25:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXv5pqkP2q+yFdsZs81b7nfoaEj2raocG5XS39HD9aG62y2QUNleBCtqQOFLwuhnMvXHwVpe X-Received: by 2002:a05:6402:43cf:b0:472:f7c1:361 with SMTP id p15-20020a05640243cf00b00472f7c10361mr5580899edc.29.1673997912636; Tue, 17 Jan 2023 15:25:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673997912; cv=none; d=google.com; s=arc-20160816; b=bT9nqTmNVsiQ26Y88tqrUyOsJp9A8uy4XQhuCAk0Q6NrvQYVDSu3+vnDpff2s/XWpP gdau1N2/rHZps0LpdiisKPIUbWPE7qLusQ1+WrxKd2xl8DLSYcUGZpfV1lVh9U8CYiZF 3XVBBJbZJk8boLIttCcR+X0Q0YAFj5hotRWGuSw/AiaZu6aWdbtYnEjEY12VLyDoivkJ s5HtcYNW2cHSmV5LhICZhl/hwTYWcNHQoyQVD5G3bqb9l6qpvErdlxXYztxARgrMecrw XOuJ3joY8nv7Z7T/le214onWnlOPQ+84ZMlGKXQduZO3R9Y85Y3+gPGPXroWEScnUh/U 1pVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=2pVx7h4GXYwRMqM2mQoWvBx9P7rA8jeO4z/gGfLdACY=; b=z5aHn9eBcBuXCI64b4DzUrYadhdtlc1W3xqirwjY2rsDsEEduGGL+jCcR9r0sBXW5v JAZiTITk3UlU59JFSXs0zXpGDB5zAeDrwVvcZ9/s0LGSBXjqb0XKjB+ljegfM5bg+iJP JJAlfgtbyvdzLDQbiJVdGZIk3IPsNED/c6hf03Ki4dxXDDoSC2fGWUnihxSPLzlvdUYL PS6w9by7IqZxtygRtA4Lq48xJcQkyfUxdSyXA4SMXy1tg3QpbyU9frzSyLlEdJpRGW28 z3moaXvztC0DmGFdjPwfdaqm2e9qGpcPBb1i2j534IkyWV5q+LpCd/7ix0EEU4+OOKER YJaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iC3f3HnS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t35-20020a056402242300b00499b463ebaesi28565663eda.605.2023.01.17.15.25.00; Tue, 17 Jan 2023 15:25:12 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=iC3f3HnS; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229463AbjAQWtq (ORCPT + 46 others); Tue, 17 Jan 2023 17:49:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229916AbjAQWrt (ORCPT ); Tue, 17 Jan 2023 17:47:49 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAE5532520; Tue, 17 Jan 2023 13:47:52 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id v6so46990252edd.6; Tue, 17 Jan 2023 13:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=2pVx7h4GXYwRMqM2mQoWvBx9P7rA8jeO4z/gGfLdACY=; b=iC3f3HnSOhWbWpnmiHeT4Y1TwZbjcLUEV/+SjFxpwG68ZSWNmjeL8fHcXpAyPK9RLW HCX/cez0yt2XzCZqUTCgc2Un7XjcgAuOrzpIk5bB8QfKrT8fQJm3XHO0wzjP23U1MBQt HhhY+qq+WHbXokrCaxNzMSs/BAS2vQqzgY8jHK923/9XUq+iN7CZO7uBuCa613ZpRMIY Ki7ya2L8zmCgDefO/EJNafKrQkqik9+qa9XZyZpFuKRsIVqMa4KoK6Pw3YhvX8L4QRMD JfMhWlsXEFxyULcfNc0EsxU1qopQxfTxCFQI/hCtDoJc0pssp3W94ih/U4jCyeW9eQ5O aRqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2pVx7h4GXYwRMqM2mQoWvBx9P7rA8jeO4z/gGfLdACY=; b=sqj11gCRC8a18cK5eOa46IIY5cwJ1fvM/ZCe3BBmQxRHajFB/U1MmlSdtXBTczXSJQ 48VsjXzeqwH6E/DqIj3/YlPuY6ntcFPI5Et0yVdCZwPHgd/wom1IF62l7xy4PHZdFj4z gM1pNzu980rkkqbP/YA6UlLBliuDqKqzIXJNgsBM6RcQHEs5hXESySI3oqXOaAru/rka ECJDa4kR3UigD/ePya/25KAzb6PNxCKNUx2B7oV8iaKu3qUaNog31TgU/oFcvn5YIp0E naloBi0n12vcLK1gNfCkhbPq8Oi3tN3BZJkN9K0iKVCuglt55qLrMBn5WJEEGdvjP75I ABIg== X-Gm-Message-State: AFqh2kqS2M+FxDIZeYfBFYcLzLhIA72kpyExiT2H2/vthY304K45g0dq CKn2tR7Y3E4upfIRUMmSiy8= X-Received: by 2002:a05:6402:449a:b0:499:376e:6b2b with SMTP id er26-20020a056402449a00b00499376e6b2bmr4744457edb.0.1673992070706; Tue, 17 Jan 2023 13:47:50 -0800 (PST) Received: from gvm01 (net-5-89-66-224.cust.vodafonedsl.it. [5.89.66.224]) by smtp.gmail.com with ESMTPSA id m17-20020a50ef11000000b0049c4e3d4139sm5754220eds.89.2023.01.17.13.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 13:47:50 -0800 (PST) Date: Tue, 17 Jan 2023 22:47:53 +0100 From: Piergiorgio Beruto To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Oleksij Rempel , mailhol.vincent@wanadoo.fr, sudheer.mogilappagari@intel.com, sbhatta@marvell.com, linux-doc@vger.kernel.org, wangjie125@huawei.com, corbet@lwn.net, lkp@intel.com, gal@nvidia.com, gustavoars@kernel.org, bagasdotme@gmail.com Subject: [PATCH net-next 1/1] drivers/phylib: fix coverity issue Message-ID: <5061b6d09d0cd69c832c9c0f2f1a6848d3a5ab1c.1673991998.git.piergiorgio.beruto@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Coverity reported the following: *** CID 1530573: (UNINIT) drivers/net/phy/phy-c45.c:1036 in genphy_c45_plca_set_cfg() 1030 return ret; 1031 1032 val = ret; 1033 } 1034 1035 if (plca_cfg->node_cnt >= 0) vvv CID 1530573: (UNINIT) vvv Using uninitialized value "val". 1036 val = (val & ~MDIO_OATC14_PLCA_NCNT) | 1037 (plca_cfg->node_cnt << 8); 1038 1039 if (plca_cfg->node_id >= 0) 1040 val = (val & ~MDIO_OATC14_PLCA_ID) | 1041 (plca_cfg->node_id); drivers/net/phy/phy-c45.c:1076 in genphy_c45_plca_set_cfg() 1070 return ret; 1071 1072 val = ret; 1073 } 1074 1075 if (plca_cfg->burst_cnt >= 0) vvv CID 1530573: (UNINIT) vvv Using uninitialized value "val". 1076 val = (val & ~MDIO_OATC14_PLCA_MAXBC) | 1077 (plca_cfg->burst_cnt << 8); 1078 1079 if (plca_cfg->burst_tmr >= 0) 1080 val = (val & ~MDIO_OATC14_PLCA_BTMR) | 1081 (plca_cfg->burst_tmr); This is not actually creating a real problem because the path leading to 'val' being used uninitialized will eventually override the full content of that variable before actually using it for writing the register. However, the fix is simple and comes at basically no cost. Signed-off-by: Piergiorgio Beruto Reported-by: coverity-bot Addresses-Coverity-ID: 1530573 ("UNINIT") Fixes: 493323416fed ("drivers/net/phy: add helpers to get/set PLCA configuration") --- drivers/net/phy/phy-c45.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c index cff83220595c..9f9565a4819d 100644 --- a/drivers/net/phy/phy-c45.c +++ b/drivers/net/phy/phy-c45.c @@ -999,8 +999,8 @@ EXPORT_SYMBOL_GPL(genphy_c45_plca_get_cfg); int genphy_c45_plca_set_cfg(struct phy_device *phydev, const struct phy_plca_cfg *plca_cfg) { + u16 val = 0; int ret; - u16 val; // PLCA IDVER is read-only if (plca_cfg->version >= 0) -- 2.37.4