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=-11.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6D6E4C433EF for ; Thu, 2 Sep 2021 23:22:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4BAE660249 for ; Thu, 2 Sep 2021 23:22:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347912AbhIBXW6 (ORCPT ); Thu, 2 Sep 2021 19:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232902AbhIBXW5 (ORCPT ); Thu, 2 Sep 2021 19:22:57 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A1E2C061575; Thu, 2 Sep 2021 16:21:58 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id j1so2437875pjv.3; Thu, 02 Sep 2021 16:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=w3ELMaiMGVzeiZKVnEuy5c21O8XgJn0C7FUAaHWvY8s=; b=Wqh6m5RVpa25LZOyLKGm39QPCKMNJDJyPf5zhT5SVgJFXbOikfe3YSzq+IsWsx84/6 fKPm9jq10do4vGlYItOS0IrxMhany9VGTHnn7B4EdLD02IDWuKd3CAZeSAWWtb7BVhhS RaV1qL/JOqAiwOMFzMs5/3+Ri2lZPB4pDeAqPCa38EqoD+YMoh9RyvbYhFX0FnJIvXC9 VyEarvmu+klboxhMbJemVNx+dDFrsrRs3RLjaYN41vHHKm42+dNsO2RYs+xVC9vbQNIk aTsEGPsl2ty9C7FgvsflcXVGPE5oR/yCHzG/jAPvzjViiYHpiay1EVxJ4sv5qVZPA2pW gsAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=w3ELMaiMGVzeiZKVnEuy5c21O8XgJn0C7FUAaHWvY8s=; b=SkyJ4T4rnyuiNO8WNxdf91gfASsiXslfqZgjZQC60dt2EuN9COOVi1QlwIlCcH06ta Vn2TnKRsCTzvCXx/qc8p7GO/Bw5f+jMHZ9vRYlyv62+KevItT+D6XS8oifBw93880gQk 2KK4Usg9SND4pTmVZVEvqc4NPDhKyn8g1mcqYDwtD8kL3QZAy2jEEdPg5qRYKphKXWeH Se/tSX54lCdJ713LWufJM0smFa+cI3d8UHQ8sON+Ss/9fCP+VGnWkIPMnJ52R/4rmgYa xIlR3gm5UTy7jDiI+bmu5mSeklsneh/qJvEs6IT31p8GL6t+CyDdS8aLKWPOz+TeZB2d dKxQ== X-Gm-Message-State: AOAM531UKYe2FnOc/L/Fl2hRXDSmBbUQ7/pTXtPf2ZMajdnRklZgb9TZ Za5rDF/e2yZleN32SSBKERk= X-Google-Smtp-Source: ABdhPJyVuLtRy7L0zvj34GfyBCTPkCciUiow6O7iiDm4EbFZrjfiX4O/MtNUdvwZmOMWVUQ5VSvmLQ== X-Received: by 2002:a17:90a:4618:: with SMTP id w24mr613243pjg.168.1630624918056; Thu, 02 Sep 2021 16:21:58 -0700 (PDT) Received: from [10.230.31.46] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id h5sm2787125pfr.134.2021.09.02.16.21.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Sep 2021 16:21:57 -0700 (PDT) Message-ID: Date: Thu, 2 Sep 2021 16:21:48 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.0.3 Subject: Re: [RFC PATCH net-next 2/3] net: dsa: destroy the phylink instance on any error in dsa_slave_phy_setup Content-Language: en-US To: Vladimir Oltean , netdev@vger.kernel.org Cc: Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Jakub Kicinski , Vivien Didelot , Vladimir Oltean , linux-kernel@vger.kernel.org, Linus Walleij , =?UTF-8?Q?Alvin_=c5=a0ipraga?= , ACPI Devel Maling List , kernel-team , Len Brown References: <20210901225053.1205571-1-vladimir.oltean@nxp.com> <20210901225053.1205571-3-vladimir.oltean@nxp.com> From: Florian Fainelli In-Reply-To: <20210901225053.1205571-3-vladimir.oltean@nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 9/1/2021 3:50 PM, 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 Reviewed-by: Florian Fainelli -- Florian