Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5043221pxb; Mon, 15 Feb 2021 08:05:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwP+4J2e6EplV/xkc7ktv/r+/wPDYnd0JjRjpyc3zEFALCRKgCdzQVZuIWJrxNvgM9l8GOx X-Received: by 2002:a17:906:4f96:: with SMTP id o22mr15800412eju.511.1613405133096; Mon, 15 Feb 2021 08:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613405133; cv=none; d=google.com; s=arc-20160816; b=T3YTTChoGX5GERplwxGTJ5GbYtjFxGsTG7fkXbEzxMYtFTVjKqQPfg+2/SNkvPE79N FvBxG6uZWrtSIetCnwSBG1/eWkfmvY5pZDaaDgvOIIFeSjdAtWILM3/sEodlEjRSJ3VR QLn8CPIMLX2CqNBZV32p9eL+7bMUeqzFjzyN/5/9QzaTdFty2KQUDELAHuTvJ3eCRczH Dz4s0d4f0WlA7R/SLIZ3axHLavJKXaQeSpN+pdZXXha+ERzOr5MtybgzPYZJnnug7u+u rPscnPf6OIf0w9DlcNqzcmR97ZVsai1zjv9CRDPxBKTRx4HtsYTZnqc8Iyka1BZxBwtf HoWw== 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=Y7avT3nX20GF4DdVA+1KRC/XIqHDcmPk6Uabh+F6eZQ=; b=aStsMFdNzw5LxRslE9bp/mqOFcskjTXsAU59V7OjqmhWHet1TxGO3idD/PHosx3xcX Wy0g1bGaYJS0Fk92ugxfOEEMzi16MKZuSNXsp7rpbvnVuE6w1SV+ne9CXX8GBHwAe6SE P0693Rb4ZYk4CpeOyhhbW7bw/wKBfLbcLqOejlklfsQ6Mk7ykqJ0vVj2QXXTwC/UWUPO dbALLSfMdycNDzsuw8Mi9kS88F9C2fu5bviPyorfGE1hGDXTrZ0USu16wyyslgdRiQvN TSbTQgwhPkqijL1TLcEmTMi8TdXTeKmSI5r1i6eqxpGq2aBj7RvsYmGcjg/IaeG8c2Nv NSnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gOz+OhkN; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q9si4762640edv.547.2021.02.15.08.05.09; Mon, 15 Feb 2021 08:05:33 -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=@linuxfoundation.org header.s=korg header.b=gOz+OhkN; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232773AbhBOQDV (ORCPT + 99 others); Mon, 15 Feb 2021 11:03:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:45436 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231168AbhBOPdE (ORCPT ); Mon, 15 Feb 2021 10:33:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6832F64EB9; Mon, 15 Feb 2021 15:30:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403028; bh=cSeKpfqJ+3KVnWkjHrHd6MlfwlbX9h0mEPo8NLxpLzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gOz+OhkNcZy7xa6YiKLptaQYDR1kbIH/PR7DqoK6dFA0ocdiPh7lo9a0+FvE/qZHM 01hVn8MwX2RPgWfP7vBd6Q/QAECiy3cPyrzUvWQRlkeu3zLAgy/kHBbvBqhGfbRquP TXcxNtsGlnuidHpf/MjnDif0SUAklpMPMseFOR9U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Andrew Lunn , Florian Fainelli , Jakub Kicinski Subject: [PATCH 5.4 51/60] net: dsa: call teardown method on probe failure Date: Mon, 15 Feb 2021 16:27:39 +0100 Message-Id: <20210215152717.008911216@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152715.401453874@linuxfoundation.org> References: <20210215152715.401453874@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean commit 8fd54a73b7cda11548154451bdb4bde6d8ff74c7 upstream. Since teardown is supposed to undo the effects of the setup method, it should be called in the error path for dsa_switch_setup, not just in dsa_switch_teardown. Fixes: 5e3f847a02aa ("net: dsa: Add teardown callback for drivers") Signed-off-by: Vladimir Oltean Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20210204163351.2929670-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/dsa/dsa2.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -399,18 +399,21 @@ static int dsa_switch_setup(struct dsa_s ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev); if (!ds->slave_mii_bus) { err = -ENOMEM; - goto unregister_notifier; + goto teardown; } dsa_slave_mii_bus_init(ds); err = mdiobus_register(ds->slave_mii_bus); if (err < 0) - goto unregister_notifier; + goto teardown; } return 0; +teardown: + if (ds->ops->teardown) + ds->ops->teardown(ds); unregister_notifier: dsa_switch_unregister_notifier(ds); unregister_devlink: