Received: by 10.223.185.116 with SMTP id b49csp1045887wrg; Fri, 23 Feb 2018 10:56:33 -0800 (PST) X-Google-Smtp-Source: AH8x226feCVvkdbK1D9CIwEx0mtGEZKJtAk/8+M0Sf+bFuOQDlzXXjuWxhoctXh5+/7bXnbEfMJr X-Received: by 2002:a17:902:7182:: with SMTP id b2-v6mr2540752pll.331.1519412193412; Fri, 23 Feb 2018 10:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412193; cv=none; d=google.com; s=arc-20160816; b=a6Oj11fGAroN8f3KKSiDvlVgeSwx/ROvGX7iru3ZM00U2TuWxfkL7OkiAojd++1yp7 Xh8WwNAW+kgOeO2E5+MSZdwJNveS4rJclTQWXaQkZPS55Fzrmn9oUiE9mTyNwCZDFn0j oIJ868x7xsAHV8/v8U7/vnpIorLSS7XIt71nYS8uaULaH5Wr98l0OjwvV11unITZqsHb /3vcNrXA+EQQDL6/aqj68pdndm/LvuaSpfNhcuDLePopAJlxbVWVqvpnxmKd/PHQt8Ir CHAEp5AV44jK2Wvh2nKmUur5ZrSvlGcg+p4wcb56iuLSYV0j7UZ1nrdaXsilOGOz2d2s wFPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=baXbnTUOXF+T2hVpJG1atca3fnNHt5qe26MdZ7hFgqE=; b=XvSFNBy3s9BRma7VrKFKGivJMsOwos5gK1FBWp9xn4aEiypreFIEPI1hTr2J//Jj3b 1nTwVjZqvXArZz8UfBFOwTNQ3wtnd6PCZ1z9OecgCAS+GR0LYmVM6jbtl/9x9CZuUXMN 6RHx9uqh5ZjKGMeJZfKfwhp/eZ113khTgz4CAuezpRUY1fFZaG2tp4a0rY5rGF7YG19I ZfDrCmx5AiqfQuvYv5m2UrLIpQhJnApUPcoiPUmgEFm1AvPNcSwhwxA9xWaHtB+cXRaY cqfFotq5vogs007OZbGsjdzLX6MFM763080DmSpDqtbWsvX0zlQdf1etM+J1Ndrq5+eF QX6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y10si1412746pgv.456.2018.02.23.10.56.17; Fri, 23 Feb 2018 10:56:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965056AbeBWSzA (ORCPT + 99 others); Fri, 23 Feb 2018 13:55:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47992 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935146AbeBWSy5 (ORCPT ); Fri, 23 Feb 2018 13:54:57 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 61E9F1217; Fri, 23 Feb 2018 18:54:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , Vivien Didelot , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 125/159] net: dsa: mv88e6xxx: Unregister MDIO bus on error path Date: Fri, 23 Feb 2018 19:27:13 +0100 Message-Id: <20180223170758.323061227@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrew Lunn [ Upstream commit 3126aeec5313565bfa19e2dd8fd7e3c3390514cb ] The MDIO busses need to be unregistered before they are freed, otherwise BUG() is called. Add a call to the unregister code if the registration fails, since we can have multiple busses, of which some may correctly register before one fails. This requires moving the code around a little. Fixes: a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO busses") Signed-off-by: Andrew Lunn Reviewed-by: Vivien Didelot Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/mv88e6xxx/chip.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2153,6 +2153,19 @@ static const struct of_device_id mv88e6x { }, }; +static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) + +{ + struct mv88e6xxx_mdio_bus *mdio_bus; + struct mii_bus *bus; + + list_for_each_entry(mdio_bus, &chip->mdios, list) { + bus = mdio_bus->bus; + + mdiobus_unregister(bus); + } +} + static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip, struct device_node *np) { @@ -2177,27 +2190,16 @@ static int mv88e6xxx_mdios_register(stru match = of_match_node(mv88e6xxx_mdio_external_match, child); if (match) { err = mv88e6xxx_mdio_register(chip, child, true); - if (err) + if (err) { + mv88e6xxx_mdios_unregister(chip); return err; + } } } return 0; } -static void mv88e6xxx_mdios_unregister(struct mv88e6xxx_chip *chip) - -{ - struct mv88e6xxx_mdio_bus *mdio_bus; - struct mii_bus *bus; - - list_for_each_entry(mdio_bus, &chip->mdios, list) { - bus = mdio_bus->bus; - - mdiobus_unregister(bus); - } -} - static int mv88e6xxx_get_eeprom_len(struct dsa_switch *ds) { struct mv88e6xxx_chip *chip = ds->priv;