From patchwork Mon May 8 21:48:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jon Mason X-Patchwork-Id: 9716749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 717E5602A0 for ; Mon, 8 May 2017 21:49:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E4E1206E2 for ; Mon, 8 May 2017 21:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 616ED265B9; Mon, 8 May 2017 21:49:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0709206E2 for ; Mon, 8 May 2017 21:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=WAAvIay1Wh01G/Xkx+gg6CT+B3hn+Iyn87ZClWG5FfQ=; b=r+E wwQcHxAkDemsvPLKCU7sxc9U04ky+33VcCsZEvDZJ4o3AjHViqDDqI8m8r5M7bri6vzevdZ0vttIH CbZ1/W95FJTFf7EzP0jfCakyLFp6EZmmhqct/g3ZQP/AuYLX8jX5LCY1ia1D3+2LKDrRD68oPVXBm /Bpgdp59kGLoPkkN1FSmga9Kr8sL3gElmIPKQ2V0e3vBH/kI19wdaAAstGVYIcdiLWlsDpZRaXlgq Kemz6GqAc57TlB4uiGmCfpoADavPz6BHN9GGVw+EwpV472zWOpDalgeBU6UFyudtDXaviQOPxpdCf jBOB/tt2r3nm3o2pkbrlLfp1VUo9/Yg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d7qWt-0006Vb-Id; Mon, 08 May 2017 21:49:19 +0000 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d7qWq-0006TG-Cn for linux-arm-kernel@lists.infradead.org; Mon, 08 May 2017 21:49:18 +0000 Received: by mail-wr0-x229.google.com with SMTP id l9so55170571wre.1 for ; Mon, 08 May 2017 14:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id; bh=rZtH8mwIJwJGPF74lBNO3WMVNQWCnD73pF0LfUat1d8=; b=ShSpIn7Z9kMBz5kLC9vItoFRky32aNhRKjlwZ9vLmX35UKMQsJWqg9zvLmEo3osqPo AApvxQkapNEVAoA5qQDxV+B6mkRR/2oetiZGkMkRyZeOm1o262w+EYVbBBsF8sisk9gw QtZHLxHz5w0mjBgBMxYw2X/Xp2tkWtFEji+14= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rZtH8mwIJwJGPF74lBNO3WMVNQWCnD73pF0LfUat1d8=; b=DGrWmWFw6TPTWjuCrukIHua/WVZRYzMMNeyaOR0CgJkk7N1Gp5E0xlrSuwkyJXqMAK Tj8+6xQrsvgEuyJADurx9ZAIlHaQQnru7JsSuVJR+/ymdo6y62NZUo2ntd6kTsLp3yO/ Yqlnt31IoMpuBQJ1na45ELoqTnQzjMISQfE8acCFSllusTMfuU9sPYDBxi63sfJVXCLT E8j4+kJvEUhfNUjfHUNnOfzmcKdXy41NZacbsSPjHncD/XAjubuGfrCwVW+1uyBGp4cO gtVIpPgmgABqjqFJUKdikcsXOnNXvf7xMZSdq8sanfg7FFvNYVoSHp4Jq15or4psI9Gp mSDg== X-Gm-Message-State: AN3rC/5BxZRcgVQa0s/L+4ocMUUh+t5R5fY+AZ5K/O/EghyGWh4KFlCE 8IgQD5iOagAAfD9u X-Received: by 10.223.160.139 with SMTP id m11mr37821529wrm.99.1494280133919; Mon, 08 May 2017 14:48:53 -0700 (PDT) Received: from venom.dhcp.broadcom.net ([192.19.231.250]) by smtp.gmail.com with ESMTPSA id 43sm17696669wrx.26.2017.05.08.14.48.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 May 2017 14:48:53 -0700 (PDT) From: Jon Mason To: Florian Fainelli Subject: [PATCH] net: mdio-mux: bcm-iproc: call mdiobus_free() in error path Date: Mon, 8 May 2017 17:48:35 -0400 Message-Id: <1494280115-9252-1-git-send-email-jon.mason@broadcom.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170508_144916_596820_740531AD X-CRM114-Status: GOOD ( 11.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: netdev@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If an error is encountered in mdio_mux_init(), the error path will call mdiobus_free(). Since mdiobus_register() has been called prior to mdio_mux_init(), the bus->state will not be MDIOBUS_UNREGISTERED. This causes a BUG_ON() in mdiobus_free(). To correct this issue, add an error path for mdio_mux_init() which calls mdiobus_unregister() prior to mdiobus_free(). Signed-off-by: Jon Mason Fixes: 98bc865a1ec8 ("net: mdio-mux: Add MDIO mux driver for iProc SoCs") Acked-by: Florian Fainelli --- drivers/net/phy/mdio-mux-bcm-iproc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/mdio-mux-bcm-iproc.c b/drivers/net/phy/mdio-mux-bcm-iproc.c index 0a0412524cec..0a5f62e0efcc 100644 --- a/drivers/net/phy/mdio-mux-bcm-iproc.c +++ b/drivers/net/phy/mdio-mux-bcm-iproc.c @@ -203,11 +203,14 @@ static int mdio_mux_iproc_probe(struct platform_device *pdev) &md->mux_handle, md, md->mii_bus); if (rc) { dev_info(md->dev, "mdiomux initialization failed\n"); - goto out; + goto out_register; } dev_info(md->dev, "iProc mdiomux registered\n"); return 0; + +out_register: + mdiobus_unregister(bus); out: mdiobus_free(bus); return rc;