Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp5009395pxb; Tue, 28 Sep 2021 08:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvR/LzggWbCeB8R8Drf8ckM4CRNM/HISIfG7KJxGDN3yvXZGPBIXxbu9uCkCNxQhN0jKv5 X-Received: by 2002:a17:902:ab93:b0:13d:e3b5:7ec2 with SMTP id f19-20020a170902ab9300b0013de3b57ec2mr5768921plr.26.1632843909308; Tue, 28 Sep 2021 08:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632843909; cv=none; d=google.com; s=arc-20160816; b=UcAnebwLHLyyj+P5USetjwjVUvfmcH8jfWZugvaO89FosiIl9QmhzctmY9cDhGpTNi AioAy8L4qEQXfYOIiHzMFVh7poNfe27vHfOrALrw9c92LAU8T3UbZie6LPwoQHoifd7u JtHLWz3B4AR+INLcU+fPzFJBhbnnbFwRdiMECQQXPfva5kIg3WRSn8eyRZuScBR8USyy QgvSvew31MMjnLJ5TN5u/+MTsd9X/mVgHN05fBuELtCpYv9rjdMJqwun7iOHtry2ofi7 Pj0XWrrVr/A0o2CtKydcAMwQkX8QzjhhXrcvXM92ngpyT98ByFgBOXW2myyIq0TQ7FS2 NDUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gEqaAtXioo2FwTuFrHkB+GPobkG1HZy9wNfU3a0tY14=; b=qTq8S6ngQi6RQGLSCyRu7vlutYyd/o0KvA7jux3kWlbpWIRTEVEvNSdSS1DqF5PBsg s2mimt7CcY1s/BWgfl2IfGdrM19ig8st7FKIPCO9mr86ZoQG7OjJbhMwtm/PFKRCbZVB WVPKbR2KgR5w6uBRcBrxF9em6mTIBOy+gFUNBXjrbx51cOs3UKSe/wSFz5TEEmsF51Bz ko9YUObQHRitcAcZ9VD5LOSRaJTBdHP5CpoPC9V1cJg09BMEbboEaYblPTDk1R3OCDl5 /Rb2JvtdGhtH0IcY1s9ScWbL+FcaR2F6+JEYq8ofL2qudI9hqU8tki8kmKX86vrL0X2a ZwVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=AOKwRVZg; 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 y2si3774482pjj.23.2021.09.28.08.44.51; Tue, 28 Sep 2021 08:45:09 -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=AOKwRVZg; 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 S241679AbhI1Png (ORCPT + 99 others); Tue, 28 Sep 2021 11:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241652AbhI1Pnd (ORCPT ); Tue, 28 Sep 2021 11:43:33 -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 E5EAAC06161C; Tue, 28 Sep 2021 08:41:53 -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=gEqaAtXioo2FwTuFrHkB+GPobkG1HZy9wNfU3a0tY14=; b=AOKwRVZgUda+mGFdDQDdc+wOPN 5pZO0SlRH+RqGp2oEsVJzKCDIzWDsHp8cmduPanzYl+XwTbNR/zqF/wir1MjcOqASOet9I7qMvXdy WKV8JtBh18ub5B2JcD4SMRZP9XtLB86vnQbKTA096qpqxhdOgO0xwrvxfb4m9PXiPyt4n95g6d4yQ fEcnD3lV3A7yYOoWr9Zok9+I3T5zVv9pNfYwZt14tPpDnh4w9o9xEDAWTugq3cv7sTUcaFnkEtVbp GARnE5OVgXWWDSoicg9YaUzgyPi5c2wWxZczmx7qE62Zkb6UFGlHns3JXjPhlme5tXY79HF+o+yDp UTqUMrCQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:54832) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mVFEi-0001H0-45; Tue, 28 Sep 2021 16:41:40 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mVFEe-0001rm-PR; Tue, 28 Sep 2021 16:41:36 +0100 Date: Tue, 28 Sep 2021 16:41:36 +0100 From: "Russell King (Oracle)" To: Dan Carpenter Cc: Pavel Skripkin , Yanfei Xu , Bartosz Golaszewski , andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, kuba@kernel.org, p.zabel@pengutronix.de, syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Dongliang Mu Subject: Re: [PATCH] net: mdiobus: Fix memory leak in __mdiobus_register Message-ID: References: <20210928092657.GI2048@kadam> <6f90fa0f-6d3b-0ca7-e894-eb971b3b69fa@gmail.com> <20210928103908.GJ2048@kadam> <63b18426-c39e-d898-08fb-8bfd05b7be9e@gmail.com> <20210928105943.GL2083@kadam> <283d01f0-d5eb-914e-1bd2-baae0420073c@gmail.com> <20210928113055.GN2083@kadam> <20210928135207.GP2083@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210928135207.GP2083@kadam> Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 28, 2021 at 04:52:07PM +0300, Dan Carpenter wrote: > On Tue, Sep 28, 2021 at 01:58:00PM +0100, Russell King (Oracle) wrote: > > > > This thread seems to be getting out of hand. > > The thread was closed. We need to revert Yanfei's patch and apply > Pavel's patch. He's going to resend. > > > So, I would suggest a simple fix is to set bus->state to > > MDIOBUS_UNREGISTERED immediately _after_ the successful > > device_register(). > > Not after. It has to be set to MDIOBUS_UNREGISTERED if device_register() > fails, otherwise there will still be a leak. Ah yes, you are correct - the device name may not be freed. Also... * NOTE: _Never_ directly free @dev after calling this function, even * if it returned an error! Always use put_device() to give up your * reference instead. So yes, we must set to MDIOBUS_UNREGISTERED even if device_register() fails. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!