linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, kuba@kernel.org, buytenh@marvell.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
Subject: Re: [PATCH] phy: mdio: fix memory leak
Date: Mon, 27 Sep 2021 22:17:51 +0300	[thread overview]
Message-ID: <68ed78d0-4e72-cbb5-bfa8-d7a92ea7a377@gmail.com> (raw)
In-Reply-To: <20210927112017.19108-1-paskripkin@gmail.com>

On 9/27/21 14:20, Pavel Skripkin wrote:
> Syzbot reported memory leak in MDIO bus interface, the problem was in
> wrong state logic.
> 
> MDIOBUS_ALLOCATED indicates 2 states:
> 	1. Bus is only allocated
> 	2. Bus allocated and __mdiobus_register() fails, but
> 	   device_register() was called
> 
> In case of device_register() has been called we should call put_device()
> to correctly free the memory allocated for this device, but mdiobus_free()
> was just calling kfree(dev) in case of MDIOBUS_ALLOCATED state
> 
> To avoid this behaviour we can add new intermediate state, which means,
> that we have called device_regiter(), but failed on any of the next steps.
> Clean up process for this state is the same as for MDIOBUS_UNREGISTERED,
> but MDIOBUS_UNREGISTERED name does not fit to the logic described above.
> 
> Fixes: 46abc02175b3 ("phylib: give mdio buses a device tree presence")
> Reported-and-tested-by: syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>


I've just found, that this syzkaller bug has been closed by Yanfei's 
patch [1], but Yanfei's Reported-by: is wrong, IMO.

Yanfei's patch fixed other memory leak and it's not related to bug 
reported by syzkaller. If you take a look at log [2] you won't find 
error message about mii_bus registration failure, i.e the error happened 
a bit latter (more precisely in mdiobus_scan()).

Since, Yanfei's patch is already applied, we cannot remove this tag, so 
I am informing you about this situation to break possible confusions 
about 2 different patches with same Reported-by: tag :)


Thanks


[1] 
https://lore.kernel.org/netdev/20210926045313.2267655-1-yanfei.xu@windriver.com/

[2] https://syzkaller.appspot.com/text?tag=CrashLog&x=131c754b300000


With regards,
Pavel Skripkin

  reply	other threads:[~2021-09-27 19:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 11:20 [PATCH] phy: mdio: fix memory leak Pavel Skripkin
2021-09-27 19:17 ` Pavel Skripkin [this message]
2021-09-28 20:39 ` [PATCH v2 1/2] Revert "net: mdiobus: Fix memory leak in __mdiobus_register" Pavel Skripkin
2021-09-28 20:40   ` [PATCH v2 2/2] phy: mdio: fix memory leak Pavel Skripkin
2021-09-29  6:22     ` Dan Carpenter
2021-09-29 23:48     ` Jakub Kicinski
2021-09-30  5:55       ` Pavel Skripkin
2021-09-29  6:32   ` [PATCH v2 1/2] Revert "net: mdiobus: Fix memory leak in __mdiobus_register" Xu, Yanfei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=68ed78d0-4e72-cbb5-bfa8-d7a92ea7a377@gmail.com \
    --to=paskripkin@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=buytenh@marvell.com \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+398e7dc692ddbbb4cfec@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).