Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2462563rwb; Wed, 30 Nov 2022 06:59:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf7qkjnaJVpBUaXqyBXLHhAQ9137h5FvsN/9JoWe9p9Bwf7DbnuyMyL75GdoOwy7HSsw8Sca X-Received: by 2002:aa7:d556:0:b0:45c:6467:94e2 with SMTP id u22-20020aa7d556000000b0045c646794e2mr55547373edr.295.1669820380345; Wed, 30 Nov 2022 06:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669820380; cv=none; d=google.com; s=arc-20160816; b=OjSq+V67F+ynDjYx6rmtpe8XGveMl+0EcSHmn5OVzFkqIzoWMQkq0L2Xk4MIWowU6m U+Or5IVoakYg7VZo7nnTSoE5D+lShxkXJijeBYXFmhrBi56VPq56xTqFD4j6ir2o3CBq BrDCTYv7SkFUDv7JOs8zfQUsdKBdbGkodFHMfldQ0NVUzRZfOEKWjbAJ3Y/h2guM1qep D3KpiBOjIVGqgQd5s6QKsOesZI10yCivhdC+MR3KM1QkATS1B68clQ5ALMZx0l46/yu4 L6zOZvSutOqjZsSzxaDk4wMYnzNE2uP3RqrLO82BixThSFmoTmu8djh7ZqcYGHjSfuPV U8zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EdqRD5rXX4gnusjvl0mw95+Gy4h7s2c/sLQbTJEpFGo=; b=izM1tJkeMHaT1cYn8iHcHX6rlqhwojr6Mz5K+ilpZKlVngRttJGB3A6NnccHpHnRIF 1JZtDZgXZ5E5/kExHFRDr4oE8/z6c8ule0E86mFMpJdqhlRBfYpIIp9SguT6HhRSn5dp uUmMHzIcwDxibJ58YuFC2byI7qGOZ95RwZmh1IhxWqlWv20nEhe0xVqqLJP+w+GXImF1 AKP2joBHBFBUtBWodoSSnwV7IKC7LqFONfE9E6JbweH2AtlLqZGVtW2t2xTS8fkRHDdV PlABwZpezZFB1A052jrPyLId/eyEo4H126WQ0oY3CiWysg+F5LmF9Z+D31vzZGYKphwF 3DfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=KzMTndQ8; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg39-20020a170907a42700b007ae2dfe8b76si1665441ejc.76.2022.11.30.06.59.19; Wed, 30 Nov 2022 06:59:40 -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=@microchip.com header.s=mchp header.b=KzMTndQ8; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbiK3Opg (ORCPT + 83 others); Wed, 30 Nov 2022 09:45:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiK3Opf (ORCPT ); Wed, 30 Nov 2022 09:45:35 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46FB32EF53; Wed, 30 Nov 2022 06:45:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669819533; x=1701355533; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=7OXz1JQfXpxmshc7RVji/7ppQefNBiE4Gk2wpXgkYeI=; b=KzMTndQ8DAnZtTITE5++As5d2aA1Nhip9QtpyKVqw4SXNAMuwvhkt7ye eD/lxVQXleqcKA4dEUUytI7Q0q8Cs8uPD9U2CVn75XimnGqIAM9ahhNfb nI+b6BltGiY8ORRIlgpHXU9vH/uYaW3M5K+q7KhyTNXcG5ny6ZptfGwHi YQYp55t1U2bwtaDB3RQS5uxDKXKayAiQYAW3sffMlNixIfQka9qqhNfzV eDPLc/KBGJPoOUSU92hmg1yu/S31Rqq2jtQKmfKX02idyZww27+LZQ+Si a+rEXl8njIv77GA9iLH9R1paWU6hvxF5ZeXARuL9IgWadTmHIPwIUZ2Xx A==; X-IronPort-AV: E=Sophos;i="5.96,206,1665471600"; d="scan'208";a="191147978" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Nov 2022 07:45:32 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Wed, 30 Nov 2022 07:45:31 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Wed, 30 Nov 2022 07:45:31 -0700 Date: Wed, 30 Nov 2022 15:50:34 +0100 From: Horatiu Vultur To: Divya Koppera CC: , , , , , , , , , , , Subject: Re: [PATCH v3 net-next] net: phy: micrel: Fix warn: passing zero to PTR_ERR Message-ID: <20221130145034.rmput7zdhwevo2p7@soft-dev3-1> References: <20221129101653.6921-1-Divya.Koppera@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline In-Reply-To: <20221129101653.6921-1-Divya.Koppera@microchip.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 The 11/29/2022 15:46, Divya Koppera wrote: Hi Divya, > Handle the NULL pointer case > > Fixes New smatch warnings: > drivers/net/phy/micrel.c:2613 lan8814_ptp_probe_once() warn: passing zero to 'PTR_ERR' > > Fixes Old smatch warnings: > drivers/net/phy/micrel.c:1750 ksz886x_cable_test_get_status() error: > uninitialized symbol 'ret'. Shouldn't you split this patch in 2 different patches, as you fix 2 issues. Also any reason why you target net-next and not net? Because I can see the blamed patches on net branch. > > vim +/PTR_ERR +2613 drivers/net/phy/micrel.c > Reported-by: kernel test robot > Reported-by: Dan Carpenter > Fixes: ece19502834d ("net: phy: micrel: 1588 support for LAN8814 phy") > Fixes: 21b688dabecb ("net: phy: micrel: Cable Diag feature for lan8814 phy") > Signed-off-by: Divya Koppera > --- > v2 -> v3: > - Changed subject line from net to net-next > - Removed config check for ptp and clock configuration > instead added null check for ptp_clock > - Fixed one more warning related to initialisaton. > > v1 -> v2: > - Handled NULL pointer case > - Changed subject line with net-next to net > --- > drivers/net/phy/micrel.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c > index 26ce0c5defcd..3703e2fafbd4 100644 > --- a/drivers/net/phy/micrel.c > +++ b/drivers/net/phy/micrel.c > @@ -2088,7 +2088,8 @@ static int ksz886x_cable_test_get_status(struct phy_device *phydev, > const struct kszphy_type *type = phydev->drv->driver_data; > unsigned long pair_mask = type->pair_mask; > int retries = 20; > - int pair, ret; > + int ret = 0; > + int pair; > > *finished = false; > > @@ -2970,12 +2971,13 @@ static int lan8814_config_intr(struct phy_device *phydev) > > static void lan8814_ptp_init(struct phy_device *phydev) > { > + struct lan8814_shared_priv *shared_priv = phydev->shared->priv; > struct kszphy_priv *priv = phydev->priv; > struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; > u32 temp; > > - if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) || > - !IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING)) > + /* Check if PHC support is missing at the configuration level */ > + if (!shared_priv->ptp_clock) > return; > > lanphy_write_page_reg(phydev, 5, TSU_HARD_RESET, TSU_HARD_RESET_); > @@ -3016,10 +3018,6 @@ static int lan8814_ptp_probe_once(struct phy_device *phydev) > { > struct lan8814_shared_priv *shared = phydev->shared->priv; > > - if (!IS_ENABLED(CONFIG_PTP_1588_CLOCK) || > - !IS_ENABLED(CONFIG_NETWORK_PHY_TIMESTAMPING)) > - return 0; > - > /* Initialise shared lock for clock*/ > mutex_init(&shared->shared_lock); > > @@ -3039,12 +3037,16 @@ static int lan8814_ptp_probe_once(struct phy_device *phydev) > > shared->ptp_clock = ptp_clock_register(&shared->ptp_clock_info, > &phydev->mdio.dev); > - if (IS_ERR_OR_NULL(shared->ptp_clock)) { > + if (IS_ERR(shared->ptp_clock)) { > phydev_err(phydev, "ptp_clock_register failed %lu\n", > PTR_ERR(shared->ptp_clock)); > return -EINVAL; > } > > + /* Check if PHC support is missing at the configuration level */ > + if (!shared->ptp_clock) > + return 0; > + > phydev_dbg(phydev, "successfully registered ptp clock\n"); > > shared->phydev = phydev; > -- > 2.17.1 > -- /Horatiu