Re: [bug report] scsi: core: Fix possible memory leak if device_add() fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/10/23 05:26, Dan Carpenter wrote:
On Thu, Aug 10, 2023 at 08:05:21PM +0800, wangzhu wrote:
Hello Dan Carpenter:


Sorry for the patch 04b5b5cb0136 I submitted, I thought put_dev(&rc->dev) is
not the same as kfree(rc).

Then should I submit a revert patch again, or you can fix it yourself?
please let me know what I can do.

The original code was buggy and the new code is slightly buggier.

Instead of reverting, lets see if anyone knows the correct way to fix
this.  If no one comments within a week then I agree that reverting is
better than a double free.

The standard solution is to have two error paths: one error path that
cleans up the actions performed before device_add() and a second error
path with a put_device() call in case device_add() fails. See e.g.
sd_probe().

Bart.




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux