Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2167789pxb; Sat, 7 Nov 2020 11:37:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJxxS6/gQT5oaJMUN6UYF5xXG5B/CJyCDS8Ln4mvtc0fGdauoql/8VIkypHwESuMJGTleCFy X-Received: by 2002:aa7:dcd6:: with SMTP id w22mr7987956edu.19.1604777827633; Sat, 07 Nov 2020 11:37:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604777827; cv=none; d=google.com; s=arc-20160816; b=FY+V/+UoKOFaVL53vCgFGy9DDcAgG/trWatSdh0IMAx579v883d8mVEPlqdI+9SSCH EH1CbRxoHRKWSFLuuGtYl8jFnGEx+aVW0IoZ2GYVQ+Ky2zNVlK8TajGU83GTazYbPVwI HpaibCFpyo9hC5HD02xrAPV7u5MhyTWx0j2PyRZKph0ijLJfkvzF/RIJHlu7RAsGq6h/ Y1509O0HGi1yxP4JwtPuR91Ec/q4TQ6dUuSmPI2n1k1V99Tia0PMewSHphf2fIUc0k9S 7hQFF81DaMiHt/Y9O+mZjbh/HTa2sxKbB/5MlICH+Nd/oYXR7f6ifAYoHFU2X6kIq0PB b4jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=op+bNieVyMsLe91AG/wZ5VomivxtTNHlaZcGfL0M0lQ=; b=y3cDxL10zYGZWnfwZXKxuhuUOR1/3gsGhXnpu1ERxGmaQl01xEUj/S4UuivpJFNYOm 4PPrRgIWmOGPYJTBCYBSyaJWeSxqcsR5uNNAAnJaZYEM1ZqRVW8phd3sCW8R8ck3I1+s 6MHgqrpUfwAwBnDoBw3KYXNVMMqzNLeadrMJXYoSoLkyfSuY0GQ+Xw07o/jmwSb3wAu/ qgtew8iS8B/Derqz5/FhX2CQ6IciFFuOtca3E+mGHY1iFDQnL9wjJ0B87MaLXXlW/30Z CE6YTj6SvBwX828w8otwfyIVpY0ZxkInKsOGzIjdMyI9Y+M9sKG+Z7V8dWrgSyVqgAdp KUcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BrPhYw+r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f3si3628144ejc.451.2020.11.07.11.36.44; Sat, 07 Nov 2020 11:37:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BrPhYw+r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728643AbgKGTf3 (ORCPT + 99 others); Sat, 7 Nov 2020 14:35:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:46720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725836AbgKGTf2 (ORCPT ); Sat, 7 Nov 2020 14:35:28 -0500 Received: from kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com (unknown [163.114.132.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA8D620723; Sat, 7 Nov 2020 19:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604777728; bh=AjR96+yaBayijL7Wx5/CF+M4oB4bNnVhjNMokSzY7Uk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BrPhYw+rrMLsFZlKDu2tGpqYgtcQjR7sz+Macvy6nbmXUqefoxI4ztwUCMELNqBMH i6hSl2n2KID7nAY0xngZfvLkMO5dpnWzUab61en/NwoK+2RYL+WlIUQDFtyc8FEZ8r JE6onVK4n3YxpYzp/ck2X6YCHRzGZgNcH8S8KWss= Date: Sat, 7 Nov 2020 11:35:27 -0800 From: Jakub Kicinski To: Radhey Shyam Pandey Cc: , , , , , , Shravya Kumbham Subject: Re: [PATCH net-next] net: emaclite: Add error handling for of_address_ and phy read functions Message-ID: <20201107113527.18232c34@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <1604410265-30246-1-git-send-email-radhey.shyam.pandey@xilinx.com> References: <1604410265-30246-1-git-send-email-radhey.shyam.pandey@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Nov 2020 19:01:05 +0530 Radhey Shyam Pandey wrote: > From: Shravya Kumbham > > Add ret variable, conditions to check the return value and it's error > path for of_address_to_resource() and phy_read() functions. > > Addresses-Coverity: Event check_return value. > Signed-off-by: Shravya Kumbham > Signed-off-by: Radhey Shyam Pandey Any reason not to apply this to net as a fix? > diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > index 0c26f5b..fc5ccd1 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c > +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c > @@ -820,7 +820,7 @@ static int xemaclite_mdio_write(struct mii_bus *bus, int phy_id, int reg, > static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) > { > struct mii_bus *bus; > - int rc; > + int rc, ret; > struct resource res; > struct device_node *np = of_get_parent(lp->phy_node); > struct device_node *npp; > @@ -834,7 +834,13 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) > } > npp = of_get_parent(np); > > - of_address_to_resource(npp, 0, &res); > + ret = of_address_to_resource(npp, 0, &res); > + if (ret) { > + dev_err(dev, "%s resource error!\n", > + dev->of_node->full_name); > + of_node_put(lp->phy_node); I'm always confused by the of_* refcounting. Why do you need to put phy_node here, and nowhere else in this function? > + return ret; > + } > /* Restart auto negotiation */ > bmcr = phy_read(lp->phy_dev, MII_BMCR); > + if (bmcr < 0) { > + dev_err(&lp->ndev->dev, "phy_read failed\n"); > + phy_disconnect(lp->phy_dev); > + lp->phy_dev = NULL; > + > + return bmcr; > + } > bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART); > phy_write(lp->phy_dev, MII_BMCR, bmcr); Does it really make much sense to validate the return value of phy_read() but not check any errors from phy_write()s?