lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Y1T1fxYXAICqHmLi@unreal>
Date:   Sun, 23 Oct 2022 11:04:15 +0300
From:   Leon Romanovsky <leon@...nel.org>
To:     Yang Yingliang <yangyingliang@...wei.com>
Cc:     Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        yisen.zhuang@...wei.com, salil.mehta@...wei.com,
        davem@...emloft.net
Subject: Re: [PATCH net] net: hns: fix possible memory leak in
 hnae_ae_register()

On Fri, Oct 21, 2022 at 11:01:47AM +0800, Yang Yingliang wrote:
> 
> On 2022/10/21 3:43, Jakub Kicinski wrote:
> > On Thu, 20 Oct 2022 15:48:38 +0800 Yang Yingliang wrote:
> > > On 2022/10/20 8:28, Jakub Kicinski wrote:
> > > > On Tue, 18 Oct 2022 15:58:38 +0300 Leon Romanovsky wrote:
> > > > > The change itself is ok.
> > > > Also the .release function is empty which is another bad smell?
> > > The upper device (struct dsaf_device *dsaf_dev) is allocated by
> > > devm_kzalloc(), so it's no need to free it in ->release().
> > Nah ah. devm_* is just for objects which tie their lifetime naturally
> > to the lifetime of the driver instance, IOW the device ->priv.
> > 
> > struct device allocated by the driver is not tied to that, it's
> > a properly referenced object. I don't think that just because
> > the driver that allocated it got ->remove()d you're safe to free
> > allocated struct devices.
> In this driver, I see the 'cls_dev' is used as driver data and it
> unregistered
> before got removed to free the device memory, I think it's safe for now.

Empty release means reference counting doesn't really count anything.
According to your reply, cls_dev is protected from outside and its life
time bounded to upper level.

The thing is that you was expected to create that cls_dev when you did
device_initalization and release it with not-empty release function.

Thanks

> 
> Thanks,
> Yang
> > .

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ