Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp246116ima; Fri, 15 Mar 2019 01:46:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXMiOkAToLVKXnIf/R+87fgmKxdk9otpVQ42Ipy9bnxjZD2AGMNB2qdhuZSd0vgc+XqXCb X-Received: by 2002:aa7:8b93:: with SMTP id r19mr2765014pfd.163.1552639572607; Fri, 15 Mar 2019 01:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552639572; cv=none; d=google.com; s=arc-20160816; b=RCdsyh53Q5Y4K4tFXOvkyZXUBnLmwHOEXpeB6RJnSPO9opg5J3zpn9JyDjSm1xPk7X xZsxEZIGXl33bqTR7jmagGaqd9gX2hEcnVkJz60sBqb92mVzXPAHRFwJ9DmGpYu74YYP ZdelT86rdG8VGH7vIEMuhL0qc/xa7YiFHPP4mfJuqmvjbeLb5MnTPF6y3TuTxoJu7jpk 5E9vlVyq8EtIMKjOfYe3bckUytMFVfRZUDSoMxmLGtSBkMTlMU3oHi6H8mhsO9+JNiR0 kb46EQ7uThixPdoFQRIvSUlJo69FpvtRzfCcoz4V8D+DqGKIJ981X/iMLEzGfl/iA7dc h7ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=FbBZ6AI2Fsg1gACuO8w5/35TDvs4NFDMz42L8vdDk5o=; b=rfbR/HYjui2wbqGIGfa/aHASvrekZYAdnAPGyh798UhBuPZRHwPzVEt52ktIRwoAO2 jU+QBI561smdtuDJnQN0Iz99I5IJU45xrE2SLJWFgHYNgQRWeuly9VTTJJGFql7y5Ukm n6uHA1gxA1FFWrBoiAmH1fWR/V6wVm0BzJwiqcSZHx4kwNG+w0CjmDYy9VXiAfDk8i4P HQ4kEJ1DK1IfhxUoe7+SE4SJm4nURcwranWDlxqbUZKQqXGrdB9V6W3eWvEiIXZyvLAG 0VgSJnbIkmNkczR1nXs6jPHk4HU73Z6rYa2IQchOvmfk+6NQyjkGabBMK9kKk7s3Grfy 9GRQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c141si1455515pfc.169.2019.03.15.01.45.57; Fri, 15 Mar 2019 01:46:12 -0700 (PDT) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728564AbfCOIpS (ORCPT + 99 others); Fri, 15 Mar 2019 04:45:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52970 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728031AbfCOIpS (ORCPT ); Fri, 15 Mar 2019 04:45:18 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CBC7330832EA; Fri, 15 Mar 2019 08:45:17 +0000 (UTC) Received: from ceranb.redhat.com (ovpn-204-143.brq.redhat.com [10.40.204.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4536C60BF4; Fri, 15 Mar 2019 08:45:16 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jeff Kirsher , "David S. Miller" , intel-wired-lan@lists.osuosl.org (moderated list:INTEL ETHERNET DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net] ixgbe: fix mdio bus registration Date: Fri, 15 Mar 2019 09:45:15 +0100 Message-Id: <20190315084515.22983-1-ivecera@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Fri, 15 Mar 2019 08:45:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ixgbe ignores errors returned from mdiobus_register() and leaves adapter->mii_bus non-NULL and MDIO bus state as MDIOBUS_ALLOCATED. This triggers a BUG from mdiobus_unregister() during ixgbe_remove() call. Fixes: 8fa10ef01260 ("ixgbe: register a mdiobus") Signed-off-by: Ivan Vecera --- drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c index cc4907f9ff02..2fb97967961c 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c @@ -905,13 +905,12 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) struct pci_dev *pdev = adapter->pdev; struct device *dev = &adapter->netdev->dev; struct mii_bus *bus; + int err = -ENODEV; - adapter->mii_bus = devm_mdiobus_alloc(dev); - if (!adapter->mii_bus) + bus = devm_mdiobus_alloc(dev); + if (!bus) return -ENOMEM; - bus = adapter->mii_bus; - switch (hw->device_id) { /* C3000 SoCs */ case IXGBE_DEV_ID_X550EM_A_KR: @@ -949,12 +948,15 @@ s32 ixgbe_mii_bus_init(struct ixgbe_hw *hw) */ hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_SUPPORTS_C22; - return mdiobus_register(bus); + err = mdiobus_register(bus); + if (!err) { + adapter->mii_bus = bus; + return 0; + } ixgbe_no_mii_bus: devm_mdiobus_free(dev, bus); - adapter->mii_bus = NULL; - return -ENODEV; + return err; } /** -- 2.19.2