From patchwork Sat May 15 10:01:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 439749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F24E4C433B4 for ; Sat, 15 May 2021 10:01:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D20EF61155 for ; Sat, 15 May 2021 10:01:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234735AbhEOKDB (ORCPT ); Sat, 15 May 2021 06:03:01 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:10492 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232249AbhEOKCz (ORCPT ); Sat, 15 May 2021 06:02:55 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 14FA01rw005851; Sat, 15 May 2021 10:01:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2020-01-29; bh=U6eX34B2yzQy4+bs8Od93/S88vC8KKD9qpdYt49o18E=; b=W0q+KwKlG/aJtPoqPaDYkhxmx22haTjKgabtl7/C938qFPYWW5tav0C5mHSJaXXUQqm+ jdzr2XlqxLU55Fw8pb+fmxvQvzuU0lR65yZy1l9XSrRSmgRkKX0VReJtrBJNxRnyIoe6 yRaDTs3fwTTcvH1hVfL1L1UXEdnI0tlwfVTYbbozXaIYvqr4Z9aQEMOxmyiYr0tkca45 XzH/GxUKyPdkqDYxGiJBuZuaEM1wQsER+kF17ct5OOTn6Hg+E0xkyFiUwwNdDSrNamQW 7t6bkc29uSZr2Cg2+3+DRzW0vRm6TwDTKL4QfC/D1YxXA9t8J3HhkeTqsJTVMaO6sHeh 3w== Received: from oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 38j5ws02p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 May 2021 10:01:28 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.podrdrct (8.16.0.36/8.16.0.36) with SMTP id 14FA1RGf067003; Sat, 15 May 2021 10:01:27 GMT Received: from pps.reinject (localhost [127.0.0.1]) by aserp3030.oracle.com with ESMTP id 38j4b9qxsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 May 2021 10:01:27 +0000 Received: from aserp3030.oracle.com (aserp3030.oracle.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 14FA1RG2066983; Sat, 15 May 2021 10:01:27 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 38j4b9qxrv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 15 May 2021 10:01:27 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 14FA1IsA025334; Sat, 15 May 2021 10:01:18 GMT Received: from mwanda (/102.36.221.92) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 15 May 2021 10:01:17 +0000 Date: Sat, 15 May 2021 13:01:11 +0300 From: Dan Carpenter To: Andrew Lunn Cc: Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH net] net: mdiobus: get rid of a BUG_ON() Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Proofpoint-ORIG-GUID: En8Arx2MQrFBlJ5ORYFahP4nTljQ4rI1 X-Proofpoint-GUID: En8Arx2MQrFBlJ5ORYFahP4nTljQ4rI1 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We spotted a bug recently during a review where a driver was unregistering a bus that wasn't registered, which would trigger this BUG_ON(). Let's handle that situation more gracefully, and just print a warning and return. Reported-by: Russell King Signed-off-by: Dan Carpenter Reported-by: Russell King (Oracle) Reviewed-by: Russell King (Oracle) --- drivers/net/phy/mdio_bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index dadf75ff3ab9..6045ad3def12 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -607,7 +607,8 @@ void mdiobus_unregister(struct mii_bus *bus) struct mdio_device *mdiodev; int i; - BUG_ON(bus->state != MDIOBUS_REGISTERED); + if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED)) + return; bus->state = MDIOBUS_UNREGISTERED; for (i = 0; i < PHY_MAX_ADDR; i++) {