Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6293407iob; Tue, 10 May 2022 15:07:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF40TSTZfcP9eFAMBNm2/wJPHPvtEpba5hce9YedLF0y1z6B5ImYtCxMGo/QaWBJ9fRLzO X-Received: by 2002:a17:902:8645:b0:15f:2eb5:3d49 with SMTP id y5-20020a170902864500b0015f2eb53d49mr1990345plt.42.1652220443347; Tue, 10 May 2022 15:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652220443; cv=none; d=google.com; s=arc-20160816; b=tPWaoA7IoAwwhpV/Go6T/KIyhmaYnutCYGQ1i4VatsFzRsqof9qagmyi8Q6yVy43mC zIbAxx3MgqqVbj63vVsbMSjJok5+o6CRKOFqBnBTDUBPo8Ojo8Je6+S1FoXtD4q1pyTt 5k8W//IRqahFj1gE6k3t2YXw6V1mACzk/xkDZ/AWBQcMEKdzGSIs7e37ZSi5hHNeNmiI U9ZFRhqKyXxgLl05RFJ86HiaWzGAjyXaR68uEjmL6f603FRIzEHD5M8u8nn1L2HALnHq r8yRn5XTDQ4R/OdZHyHux5WvlxX9dXxDY7+eMywr9Z4EOQ41N4Jga+1nR4Cgs26NOMMz Ckhw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Jyk1T5J5KGjazyMJGgwl2XasbBkuR6nhxE9P8B4iSf0=; b=Um439LqjlpJIgM35lI1lW6YS8sWSY/Tt2eI2m2KsLUN+mEgLMSGsQFp4WIpbE6Bykl 7KbGBdwPsnqCMx6Ta1Hk+KNSTxPIyeicAXKvq6bPfYmZqftMoJeDgS7SFwat89f4UXpy l4kjpZxFnr9RvESWFBD9KSsjJ21WNqEU9XQXOAgzrrXKqaI44cYZt0AJlUXksrznLElI 1LgNN+rIsnjuRRqPggEpE2EHT5tJa6fKG+J1SQpQJvrPscMBj0Qsq0yajM+WEnMUKjx1 S4xcPl08geQiHsIvp6/YjxkvX+0n0wv7CDJrjy0mcKQyt9LlsC96+PrsIwrbWVJSfhxt +e7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f+hxl9ls; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020a170902bd8400b0015ed25c4e18si186325pls.463.2022.05.10.15.07.06; Tue, 10 May 2022 15:07:23 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=f+hxl9ls; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345311AbiEJOcv (ORCPT + 99 others); Tue, 10 May 2022 10:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344181AbiEJOHl (ORCPT ); Tue, 10 May 2022 10:07:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF2A1FB2DD; Tue, 10 May 2022 06:41:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6D07DB81DC3; Tue, 10 May 2022 13:41:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B38F6C385A6; Tue, 10 May 2022 13:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652190107; bh=+DguFpqd5mrtoufd9LyO5xc8nY3J2jiiYBm9Iwa9yZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+hxl9lsunnd/0teFmDSN9k2vFBo1bOwOWq0Torf6Dkgr2kfTielbMWz+ktmTBKmR s4NMqAEYcnbzYJHL/ekXtHERDwe5ULwA8Ljc9TlBYf4KbixIN5FQJpGdU376i4vU/+ dZvg5F++IozDtO3BXqKcILd1FkC5HhfV0Pwd0A7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shravya Kumbham , Radhey Shyam Pandey , Paolo Abeni Subject: [PATCH 5.17 090/140] net: emaclite: Add error handling for of_address_to_resource() Date: Tue, 10 May 2022 15:08:00 +0200 Message-Id: <20220510130744.183496358@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130741.600270947@linuxfoundation.org> References: <20220510130741.600270947@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 From: Shravya Kumbham commit 7a6bc33ab54923d325d9a1747ec9652c4361ebd1 upstream. check the return value of of_address_to_resource() and also add missing of_node_put() for np and npp nodes. Fixes: e0a3bc65448c ("net: emaclite: Support multiple phys connected to one MDIO bus") Addresses-Coverity: Event check_return value. Signed-off-by: Shravya Kumbham Signed-off-by: Radhey Shyam Pandey Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/xilinx/xilinx_emaclite.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c +++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c @@ -823,10 +823,10 @@ static int xemaclite_mdio_write(struct m static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev) { struct mii_bus *bus; - int rc; struct resource res; struct device_node *np = of_get_parent(lp->phy_node); struct device_node *npp; + int rc, ret; /* Don't register the MDIO bus if the phy_node or its parent node * can't be found. @@ -836,8 +836,14 @@ static int xemaclite_mdio_setup(struct n return -ENODEV; } npp = of_get_parent(np); - - of_address_to_resource(npp, 0, &res); + ret = of_address_to_resource(npp, 0, &res); + of_node_put(npp); + if (ret) { + dev_err(dev, "%s resource error!\n", + dev->of_node->full_name); + of_node_put(np); + return ret; + } if (lp->ndev->mem_start != res.start) { struct phy_device *phydev; phydev = of_phy_find_device(lp->phy_node); @@ -846,6 +852,7 @@ static int xemaclite_mdio_setup(struct n "MDIO of the phy is not registered yet\n"); else put_device(&phydev->mdio.dev); + of_node_put(np); return 0; } @@ -858,6 +865,7 @@ static int xemaclite_mdio_setup(struct n bus = mdiobus_alloc(); if (!bus) { dev_err(dev, "Failed to allocate mdiobus\n"); + of_node_put(np); return -ENOMEM; } @@ -870,6 +878,7 @@ static int xemaclite_mdio_setup(struct n bus->parent = dev; rc = of_mdiobus_register(bus, np); + of_node_put(np); if (rc) { dev_err(dev, "Failed to register mdio bus.\n"); goto err_register;