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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6565C32793 for ; Wed, 18 Jan 2023 15:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231133AbjARPuP (ORCPT ); Wed, 18 Jan 2023 10:50:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbjARPtj (ORCPT ); Wed, 18 Jan 2023 10:49:39 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F0EB53E71; Wed, 18 Jan 2023 07:47:31 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id z11so50199082ede.1; Wed, 18 Jan 2023 07:47:31 -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=NwgV158VzLBEwnGM/l7d36JtM7My51+lT57j1JGtHIs=; b=Pnsqx/b/Md5J6PPDJLVlGUEm4SDbiGA/5a+wIZ0BzNL9kaE71HxuKTBGLEhw2jqzBB +FdflJ/gXAOD+DM6pctjHZAjGPJ47Ez/GFUzuQeN5oKlp61oPm5joWM+OmnXssPl7gzb 31VI8A3Vj1zws4kF05jGunyjE/GKn2Z5hinkrtIm5zijnr3p3aKukkDIRoHGtVJS4luL 79FPNmvVXFSX1k2/Yyc/z1ubdb2yzY+InxjRRfaFIPN9x6K3jSgR0+BQwt60WN5KTjlq K+/0KxPIrzbr7YXVwXGlVylAkPREspEIxHShRN08w0s5B4en6iyrVNVds6guuzq9CJuu TQ1A== 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=NwgV158VzLBEwnGM/l7d36JtM7My51+lT57j1JGtHIs=; b=iwZMQ8bxUZzcGQdXW62Y2DqPiTG+88skgqNdngpwAGdJEiPnfzB0vYRAYxseSsDJ2q nYTTlF/GdFxQ34rsWEHc8Owo4KpJi71bAlhjjxDrOkmrrmethOVvagBzGBwhHjcyP137 F6zzRVAi6VtwLGlvVkQoEnBr0avkIxV7tXybMyJ0ecjiJ0ZZvttu1y95RmocAR/ZAl+f yLuZrb1poLNJHmS/68j79BprkK8R3IpLwMBSKQQm0qBvvO9KbpqcE7znPLpvqBFXmUxf E+9O+4TI+ed+tknL/XyyE6u59tD2KXgkK/YL5xiY/LuPxYkMaH4aP2ul306i5TV/vJHD swgw== X-Gm-Message-State: AFqh2kpG/NSaO5x/0yVzUsSu64RNZsYtQBdMqheIFKw3QuTKuUEZ2xJD GWWgLCYeoAMxLMRD7NmrXcg= X-Google-Smtp-Source: AMrXdXuydvQh3hAPzT1cMH4Ifuyjvtw1eBOZaBIdfL5iY7MyZIdfL69czWjCed/hDPV46V9cOshRKg== X-Received: by 2002:a05:6402:28ca:b0:49c:96f9:417e with SMTP id ef10-20020a05640228ca00b0049c96f9417emr7534101edb.2.1674056849884; Wed, 18 Jan 2023 07:47:29 -0800 (PST) Received: from gvm01 (net-5-89-66-224.cust.vodafonedsl.it. [5.89.66.224]) by smtp.gmail.com with ESMTPSA id v18-20020aa7cd52000000b0047eeaae9558sm6358824edw.60.2023.01.18.07.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 07:47:29 -0800 (PST) Date: Wed, 18 Jan 2023 16:47:31 +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 v2 net-next 1/1] net: phy: fix use of uninit variable when setting PLCA config Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. Reported-by: coverity-bot Fixes: 493323416fed ("drivers/net/phy: add helpers to get/set PLCA configuration") Signed-off-by: Piergiorgio Beruto Reviewed-by: Jacob Keller --- 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