Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2533421yba; Mon, 6 May 2019 07:36:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8zEn5epoNrFm0ospywIJutidR4PH6tSae4i+xiKPdudb/7UVLM1wY1ziAdu/PcuP2Hfu+ X-Received: by 2002:a17:902:28e4:: with SMTP id f91mr32122171plb.321.1557153414692; Mon, 06 May 2019 07:36:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153414; cv=none; d=google.com; s=arc-20160816; b=LJpQwTDOIGOfENNAbSdyT9d5ga3eq/w/zxnDBgNTK9RKCS2xz32E7/n6hAxGa5O/rZ t7HSp+T970KlVeb6jnJgHvotCSF2sbdRRFmqygdbX680Td9FFQqInQIVoB+mrWI/8WFf iZDgJWkQyO3aC5RnBZ/B3FHmKSheGehw8hD9zwVk0+bpxnFFXdjcAAPNLePNGecZ8uws LAA3FZOeyPg7kZ2RT/I+Zffk7D1JS8ShYOpMdE6urFj38GDNtebMxDlzz1i3q4/scQLm 4YhXbuxQr9RuPVdR+biS0416IBSA+B7RQiiWLLA5g+9+VfseNB3blSSPokKGgaSR22gu PpTA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AHu4EPWxYzBriePi8Mh6sg+r6EAzUXorV4En+NJSCCI=; b=w6/6xG8Tz8waQ19Tu98GzkFk5JtH2qjMoag4P6v6bqGa3olvn1aMMIGF8jsZpGWG7j zEFBfhBJO+C2tMoGk9+a3PsBS3XTmu9afHmlKLKIor7zf/rUtq8fmrNzIVqAC8NebvFK W+y+Sr/zhz68EYjwlUg3CCwMV+rMKKQOyERtbDF+8MOE1Bq7wUt8J6i2h4n9hXNSiL0q +MWyzSGk1N4GDiCrM0q1SnjICHWYPVFxKKxiBX8UnsMFc0Un5d2K7V/D9Ms8Tpdvs+GN yP4Dc5shFfAxTsaVIcGqpSFKW9d7AYdV4bRjIDLj2weNwd9LzDOiHMhavpoOhh9V72FI hHTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dlrMpal9; 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 q23si10879454pfh.28.2019.05.06.07.36.38; Mon, 06 May 2019 07:36:54 -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; dkim=pass header.i=@kernel.org header.s=default header.b=dlrMpal9; 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 S1726882AbfEFOfN (ORCPT + 99 others); Mon, 6 May 2019 10:35:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:55164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726861AbfEFOfM (ORCPT ); Mon, 6 May 2019 10:35:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1F2E420B7C; Mon, 6 May 2019 14:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153311; bh=c+RirpKRmLCnZH63iU9x2IOb/hAAViXjJzoHg5qZteY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlrMpal9DPgHra3yfujVCv0NbQFO7c6HaKp6yaTj0IVPzrn0Hh3fZROwbPzjDgH0U fWwqtClCqmaoXA51KRpaCx3GBAr9TYozQxq/tjrQv71ir8yVkTt4NA1Ts9dq0SVymk aHZYK20yDyff/Wm9Vat3Vw2x6a0+7qtvB9yHLNp8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ivan Vecera , Andrew Bowers , Jeff Kirsher , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 041/122] ixgbe: fix mdio bus registration Date: Mon, 6 May 2019 16:31:39 +0200 Message-Id: <20190506143058.606057843@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 7ec52b9df7d7472240fa96223185894b1897aeb0 ] 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 Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin (Microsoft) --- 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.20.1