lkml.org 
[lkml]   [2021]   [Sep]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 2/2] phy: mdio: fix memory leak
On Tue, Sep 28, 2021 at 11:40:15PM +0300, 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()
> calls just kfree(dev) in case of MDIOBUS_ALLOCATED state
>
> To avoid this behaviour we need to set bus->state to MDIOBUS_UNREGISTERED
> _before_ calling device_register(), because put_device() should be
> called even in case of device_register() failure.
>
> Link: https://lore.kernel.org/netdev/YVMRWNDZDUOvQjHL@shell.armlinux.org.uk/
> 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>

Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter

\
 
 \ /
  Last update: 2021-09-29 08:25    [W:1.345 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site