Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3114067pxm; Mon, 28 Feb 2022 12:18:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7tvYIIH9TRisn5oFumFd6sDGCGMHICyHCCK1RDKAR4EIIQJUJtCg9JmZGv6HGEP1kxjYn X-Received: by 2002:a63:161c:0:b0:372:e459:70e6 with SMTP id w28-20020a63161c000000b00372e45970e6mr18833832pgl.596.1646079501272; Mon, 28 Feb 2022 12:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079501; cv=none; d=google.com; s=arc-20160816; b=XPtQEwp98Hky+U38vW/2rnjHpki1RVgol/y4AqdTTMQ976ADaS79ixBqPaarfDA6MQ bWuTvGhZXdFVWNT4Ok+abKPWYjrrqgGxWUCjlv0xP7ycUyltvd1uK/8KG1bE7nJfqxi9 f+LKKZ7bH5nS+/2rIJqNR05TGBsxkBwC4w4hcWOPsHWLKkkaoQoYf7+TSkbASTiekzRY h7Hb4DMRc0vf8XwuVfr8bq/BGAHjsTwcB5ByqXmMWcEREGgOwOX/bSOpCr6EP5pDwFvl NTcet4Fe2PKCQT/wIrUqJIHX/lmtDcFHk90woiuQzYS1Ec1ha6o9vdH7yS5mLUZ0J+3H WDyQ== 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=RICvdX6GSAeFUfMz5ryGT9d8inficAGwWKvxoGoKez4=; b=pHnJOlAc8pQMj1/W3RI7XwqQTjecnYpP7HLVP3Hn8giBT4OJ9Uk2ql8er5J+r+SGeF iLyIvLRtDK4k4aDVP0lVtfPIFGjZgDjjWV4Bv1KyAoJxsPlQmFbxqeJGxEwliSVZazLO hfcReukO24sn7/berynJcZ/hh0fiuY3I507s6svqtp42T0LvmTckLd8FWzg49VCgMkLa XeT9OPaoYM6PS/gkLJWhIEu+sxud1ShnnV/4d55dukz+dZAmlmE7uyOH0dYeGjJjZE41 63r2juMUl4waxaeSkscOjgws1wbBr3QxIxGwH9ljiy2S9xL2JRtKcEKy6hkAAvB5TsHf wWLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OoSHnDFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s7-20020a17090302c700b0014f883280acsi10933900plk.351.2022.02.28.12.18.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:18:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OoSHnDFN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E1A3018DAA0; Mon, 28 Feb 2022 11:39:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239520AbiB1RxH (ORCPT + 99 others); Mon, 28 Feb 2022 12:53:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239121AbiB1RsF (ORCPT ); Mon, 28 Feb 2022 12:48:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8075FA1474; Mon, 28 Feb 2022 09:38:41 -0800 (PST) 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 24126B815B3; Mon, 28 Feb 2022 17:38:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A228C340F3; Mon, 28 Feb 2022 17:38:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069918; bh=e9qSJssGN+HZrIwdyr6Y6yzckhlwCSUpu93cFoY6+y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoSHnDFNY521Tt/Fl1UcIF0ypQrdo5TKElOh5rUTebQefmIdoseG5G0TM7z9nv2Qo SCzz1IZc3SFj1be15MVcL4R9Og6OdAVCWLTP0VZmRmX90FfWWb3qJnmYYTHxvnRog8 eqKCc2WSPfUPzVMcLc+LR9emJlXhKI2v19UxNgi0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauri Sandberg , Andrew Lunn , Jakub Kicinski Subject: [PATCH 5.15 060/139] net: mv643xx_eth: process retval from of_get_mac_address Date: Mon, 28 Feb 2022 18:23:54 +0100 Message-Id: <20220228172354.001537175@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172347.614588246@linuxfoundation.org> References: <20220228172347.614588246@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=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Mauri Sandberg commit 42404d8f1c01861b22ccfa1d70f950242720ae57 upstream. Obtaining a MAC address may be deferred in cases when the MAC is stored in an NVMEM block, for example, and it may not be ready upon the first retrieval attempt and return EPROBE_DEFER. It is also possible that a port that does not rely on NVMEM has been already created when getting the defer request. Thus, also the resources allocated previously must be freed when doing a roll-back. Fixes: 76723bca2802 ("net: mv643xx_eth: add DT parsing support") Signed-off-by: Mauri Sandberg Reviewed-by: Andrew Lunn Link: https://lore.kernel.org/r/20220223142337.41757-1-maukka@ext.kapsi.fi Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/marvell/mv643xx_eth.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) --- a/drivers/net/ethernet/marvell/mv643xx_eth.c +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c @@ -2700,6 +2700,16 @@ MODULE_DEVICE_TABLE(of, mv643xx_eth_shar static struct platform_device *port_platdev[3]; +static void mv643xx_eth_shared_of_remove(void) +{ + int n; + + for (n = 0; n < 3; n++) { + platform_device_del(port_platdev[n]); + port_platdev[n] = NULL; + } +} + static int mv643xx_eth_shared_of_add_port(struct platform_device *pdev, struct device_node *pnp) { @@ -2736,7 +2746,9 @@ static int mv643xx_eth_shared_of_add_por return -EINVAL; } - of_get_mac_address(pnp, ppd.mac_addr); + ret = of_get_mac_address(pnp, ppd.mac_addr); + if (ret) + return ret; mv643xx_eth_property(pnp, "tx-queue-size", ppd.tx_queue_size); mv643xx_eth_property(pnp, "tx-sram-addr", ppd.tx_sram_addr); @@ -2800,21 +2812,13 @@ static int mv643xx_eth_shared_of_probe(s ret = mv643xx_eth_shared_of_add_port(pdev, pnp); if (ret) { of_node_put(pnp); + mv643xx_eth_shared_of_remove(); return ret; } } return 0; } -static void mv643xx_eth_shared_of_remove(void) -{ - int n; - - for (n = 0; n < 3; n++) { - platform_device_del(port_platdev[n]); - port_platdev[n] = NULL; - } -} #else static inline int mv643xx_eth_shared_of_probe(struct platform_device *pdev) {