Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp699927pxb; Thu, 2 Sep 2021 12:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzhvlBkPEoC0U3rFLs8nWLEa5ZZ2+1zD9gtELOGLbrkRTdjY9Op2H23iEOcWbzzZ1jH1BK X-Received: by 2002:a17:906:8506:: with SMTP id i6mr5670498ejx.397.1630612738835; Thu, 02 Sep 2021 12:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630612738; cv=none; d=google.com; s=arc-20160816; b=Zql8UDKpd9nkn0vnrIcr+IgRKj2sTwLKE+3/11LZanASKGfy1UGaGtwnO0tz6BEX7P xcV1/TQrutyMbBq3BD3VnyQL289O8xtECI1fa7GyVd3S72g7St2T5Jp7jJaGN1siKXt9 OV2spbky/OARdBQqbr68n+T5rKbpS5Q9KWF3/SN1b4FckjU1thshl0Ckw0ZfLuwXCsYO MGvXAOUQUs7QI8sAUCs9eHnbDLjwKDTqpktuWd5H6Co2Ikf0pU+f4TIw1fIGDfckUBSV fhp92C6T7GQxNd9RBssLbv4q5PqtZCyCo07Xlr5NQsKNODvFTC20oVmIygo5zQ7eOxZx bI4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1wOKCrX3COV6DlxfudE8AnDiURX7M6vGBTgHMAhqiY4=; b=QOjQPS2qElhlWfvckZVigjxNvYCx4TJRmf7OqiLI1Cht9+ovTlpDUbgiANwuM9W8i+ 9n78zlGhoIMSH53P0ujNffvQmyFeQGUeBJZo5teO2f4e5+8jPSJuYgirgNdatc2iKPGZ AK0tHyMsObVB/5ZtUTSCb8mis4jh/q96df0b/mLDvBp5ob36WvfZcySsuuZ9C9Vr2zyl +aLWgi/eFNQ8FqbyY7RqfUY99Ld2f9OOrsbxSA3E+4/qdUl3gMlprytTQo0zWDJZkahD mU3aacvKMzefh4w1ZRt5/ko0WD91fl/GMjVm01XHY6oUnD4voZG2b0EFYIBjkTzEI4er Zy3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=rqK6AEvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si2816887ejd.52.2021.09.02.12.58.35; Thu, 02 Sep 2021 12:58:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=rqK6AEvP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344325AbhIBM03 (ORCPT + 99 others); Thu, 2 Sep 2021 08:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344074AbhIBM02 (ORCPT ); Thu, 2 Sep 2021 08:26:28 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22785C061575; Thu, 2 Sep 2021 05:25:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: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=1wOKCrX3COV6DlxfudE8AnDiURX7M6vGBTgHMAhqiY4=; b=rqK6AEvPgoByLYFRodspB7Byw 7gqMzeAVrrtGevy7S/Pe4kpxFOG541wx2HwjnEnffJUbdF5hpGnPUE5ySMo1DbZcFAzPmnds7zmp+ Jj1zgwrIxm6M0IrdmtR1pc/NjF4oW1CvyFeGIDapO7P9JKM4zZouHP9S7Vdcxy+PY9MvtgiZ3DXk+ mFmcyTwXarm08r5htAsGboZCNkAZqOtGAinHX0bvrFOY06FxWdqIlPllA4Igcplk7tTNVpClxl26y k6yQu2+qEuQvdgC0jKkB1O+Ngc3fVV9HBJzKmsm7WNRrb0nQBzJeEFDuEVjkJLHCrAEDEs2hy32+E 4bbcBfltw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:48088) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mLlma-0001P2-4n; Thu, 02 Sep 2021 13:25:28 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1mLlmZ-0007ov-0Y; Thu, 02 Sep 2021 13:25:27 +0100 Date: Thu, 2 Sep 2021 13:25:26 +0100 From: "Russell King (Oracle)" To: Vladimir Oltean Cc: netdev@vger.kernel.org, Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , "David S. Miller" , Jakub Kicinski , Vivien Didelot , Florian Fainelli , Vladimir Oltean , linux-kernel@vger.kernel.org, Linus Walleij , Alvin =?utf-8?Q?=C5=A0ipraga?= , ACPI Devel Maling List , kernel-team , Len Brown Subject: Re: [RFC PATCH net-next 2/3] net: dsa: destroy the phylink instance on any error in dsa_slave_phy_setup Message-ID: <20210902122526.GF22278@shell.armlinux.org.uk> References: <20210901225053.1205571-1-vladimir.oltean@nxp.com> <20210901225053.1205571-3-vladimir.oltean@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210901225053.1205571-3-vladimir.oltean@nxp.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 02, 2021 at 01:50:52AM +0300, Vladimir Oltean wrote: > DSA supports connecting to a phy-handle, and has a fallback to a non-OF > based method of connecting to an internal PHY on the switch's own MDIO > bus, if no phy-handle and no fixed-link nodes were present. > > The -ENODEV error code from the first attempt (phylink_of_phy_connect) > is what triggers the second attempt (phylink_connect_phy). > > However, when the first attempt returns a different error code than > -ENODEV, this results in an unbalance of calls to phylink_create and > phylink_destroy by the time we exit the function. The phylink instance > has leaked. > > There are many other error codes that can be returned by > phylink_of_phy_connect. For example, phylink_validate returns -EINVAL. > So this is a practical issue too. > > Fixes: aab9c4067d23 ("net: dsa: Plug in PHYLINK support") > Signed-off-by: Vladimir Oltean > --- > I know, I will send this bug fix to "net" too, this is provided just for > testing purposes, and for the completeness of the patch set. Probably should have been the first patch of the set. This looks absolutely correct to me. Please send for the net tree. Reviewed-by: Russell King (Oracle) Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!