Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6116793iob; Tue, 10 May 2022 10:40:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsxL7V2m4SK6EYDy2pBRAPtooGa1iPe1sViZci876fyT6WtO8IkXxJvIfvAtT9j0ytmorb X-Received: by 2002:a17:906:d550:b0:6f8:60a4:c2cf with SMTP id cr16-20020a170906d55000b006f860a4c2cfmr14900196ejc.477.1652204454579; Tue, 10 May 2022 10:40:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652204454; cv=none; d=google.com; s=arc-20160816; b=ohUnsP0DhfEJYy8rnULZr0dLsfZeD2GWPj85yLzbFqDpqwJnKuA7StYH+QJsgpExES 0sgXAlOO3qcH+y/LXSV4itUEh9lGpFQnx/W7uhTnNhjxfkLdnTlkpKL4/p4PHCTTxug+ bid8E9vIBLuJSRgMZrR3ULa1XFDll9WwTYK1iXeDl/wwiMsmmeCYwuvVh1Owv+ToB1DR 1DMahQwCHN5moMAS5pwjphn3qFZvb17pk+ZtVnFau/3uenj/MOZ5yFRh5ETZqUBOot7a cFQ91esgceKWHnQxUYGktHoetBYmh126es/SXCLUqFJ/1PZ4zPYlL+f/FSLKdOPHZYY9 9RkQ== 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=HbI51iA67Xw+URmRCBvGgnVCs+Nipo2+p+M1fYx+3Eo=; b=IQCT3LpHBZjlHjxeJCYI1F2ySwTaA555Swx3IDqy/q3rCuKad9OjCzBlDyMNX8b4hC lzSMh0HZpyoSj1MLQn4sa/G4AnG9i1RL/uX8gvWe7o4NuQy7L63ss+ArV6DtAqmWUMJl wAkI+iNAiOicSJmuPtqrmV2LN3s6MXeKRONcWQsRtD/WgDo7MnOVjhGD9fQmkTfcdHyA 1Q5iE1PoZbUWXMXUv1Tl98r1dv/3YvLABTmAjcmEKK17FfIf7c/ZnYKs/j2f2YKM7r/b yDj/moQFSD5U21PGk4lUDsa6Kvj2PySJ9jkO03CKRFciy73FfFGNKmgUftS1O1ocBhGS RVFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v8xzD2cI; 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 lb14-20020a170907784e00b006e7f908e9d5si18287350ejc.607.2022.05.10.10.40.29; Tue, 10 May 2022 10:40:54 -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=v8xzD2cI; 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 S1343581AbiEJNsP (ORCPT + 99 others); Tue, 10 May 2022 09:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243888AbiEJNcT (ORCPT ); Tue, 10 May 2022 09:32:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7739316D48F; Tue, 10 May 2022 06:23:13 -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 2885AB81D7A; Tue, 10 May 2022 13:23:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CC7BC385C2; Tue, 10 May 2022 13:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652188990; bh=WWcJJPaW4s0frkbSK/ZxJ/KyPtXnNk7ZjXtjDnn1RI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v8xzD2cI22VIfrjnr5F+wp3f0pEbiSlqsxBVHQuztb8Bl43heAcpa5alMqErEHeKt p5r3PfiG5bGdInS6mZG/TRau++J8FW09YaE05Pn42JccPzsW3kB3Erb9Y1BUlF4cM6 aZWIppBKkmnRS+cJXeTahEQP9zvnodbi6RfrVCCk= 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.4 28/52] net: emaclite: Add error handling for of_address_to_resource() Date: Tue, 10 May 2022 15:07:57 +0200 Message-Id: <20220510130730.677804403@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130729.852544477@linuxfoundation.org> References: <20220510130729.852544477@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 @@ -820,10 +820,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. @@ -833,8 +833,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); @@ -843,6 +849,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; } @@ -855,6 +862,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; } @@ -867,6 +875,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;