Re: [PATCH] net-sysfs: fix error handling in netdev_register_kobject()

From: Andy Shevchenko
Date: Thu Mar 13 2025 - 05:02:07 EST


On Thu, Mar 13, 2025 at 03:55:28PM +0800, Ma Ke wrote:
> Once device_add() failed, we should call put_device() to decrement
> reference count for cleanup. Or it could cause memory leak.
>
> As comment of device_add() says, 'if device_add() succeeds, you should
> call device_del() when you want to get rid of it. If device_add() has
> not succeeded, use only put_device() to drop the reference count'.

Okay, have you read the history of this?
6b70fc94afd1 ("net-sysfs: Fix memory leak in netdev_register_kobject")
8ed633b9baf9 ("Revert "net-sysfs: Fix memory leak in netdev_register_kobject"")
https://syzkaller.appspot.com/x/log.txt?x=1737671b200000

TL;DR: next time provide a better changelog and clean syzkaller report.

--
With Best Regards,
Andy Shevchenko