From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 9DFACFA3728 for ; Wed, 16 Oct 2019 15:51:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73D9D21835 for ; Wed, 16 Oct 2019 15:51:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.b="SWKnuxxT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405852AbfJPPvM (ORCPT ); Wed, 16 Oct 2019 11:51:12 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:48704 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbfJPPvM (ORCPT ); Wed, 16 Oct 2019 11:51:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=B2YdhfhEgWZqOqKtmmkSBnl7J2karsMTF9JaNWGz1es=; b=SWKnuxxTJ8loDpThNmUspjv0mz IC3p36PrAKtL9tp1IZgO4lCUtA53uqlL4O4okRoMJVUc6BFIgmE72tsjC7t1me4tCZ9q1lmBCYNwD XQfkQtXJMwo6GhiFZSmXTyMYxzgmGDvehHy+Lhq4vgIR41Hpcc0bO8n+syvCJDqy03LU=; Received: from andrew by vps0.lunn.ch with local (Exim 4.92.2) (envelope-from ) id 1iKlZr-0008Je-TX; Wed, 16 Oct 2019 17:51:07 +0200 Date: Wed, 16 Oct 2019 17:51:07 +0200 From: Andrew Lunn To: Daniel Wagner Cc: bcm-kernel-feedback-list@broadcom.com, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Woojung Huh , UNGLinuxDriver@microchip.com, netdev@vger.kernel.org Subject: Re: lan78xx and phy_state_machine Message-ID: <20191016155107.GH17013@lunn.ch> References: <20191014140604.iddhmg5ckqhzlbkw@beryllium.lan> <20191015005327.GJ19861@lunn.ch> <20191015171653.ejgfegw3hkef3mbo@beryllium.lan> <20191016142501.2c76q7kkfmfcnqns@beryllium.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191016142501.2c76q7kkfmfcnqns@beryllium.lan> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Hi Daniel Please could you give this a go. It is totally untested, not even compile tested... Thanks Andrew >From 235549a687ad91c1500289fb32ee1c775d06d16d Mon Sep 17 00:00:00 2001 From: Andrew Lunn Date: Wed, 16 Oct 2019 10:42:07 -0500 Subject: [PATCH] net: usb: lan78xx: Connect PHY before registering MAC As soon as the netdev is registers, the kernel can start using the interface. If the driver connects the MAC to the PHY after the netdev is registered, there is a race condition where the interface can be opened without having the PHY connected. Change the order to close this race condition. Fixes: 92571a1aae40 ("lan78xx: Connect phy early") Reported-by: Daniel Wagner Signed-off-by: Andrew Lunn --- drivers/net/usb/lan78xx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 58f5a219fb65..62948098191f 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3782,10 +3782,14 @@ static int lan78xx_probe(struct usb_interface *intf, /* driver requires remote-wakeup capability during autosuspend. */ intf->needs_remote_wakeup = 1; + ret = lan78xx_phy_init(dev); + if (ret < 0) + goto out4; + ret = register_netdev(netdev); if (ret != 0) { netif_err(dev, probe, netdev, "couldn't register the device\n"); - goto out4; + goto out5; } usb_set_intfdata(intf, dev); @@ -3798,14 +3802,10 @@ static int lan78xx_probe(struct usb_interface *intf, pm_runtime_set_autosuspend_delay(&udev->dev, DEFAULT_AUTOSUSPEND_DELAY); - ret = lan78xx_phy_init(dev); - if (ret < 0) - goto out5; - return 0; out5: - unregister_netdev(netdev); + phy_disconnect(netdev->phydev); out4: usb_free_urb(dev->urb_intr); out3: -- 2.23.0