Re: [PATCH] md: Ensure mddev object is cleaned up with kobject_put on error path

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

 



On Wed, Jul 13, 2022 at 03:06:23PM -0600, Logan Gunthorpe wrote:
> The documentation for kobject_init() clearly states that the new
> object must be cleaned up with a call to kobject_put(), not a
> kfree() call directly.
> 
> However, the error path in mddev_alloc() frees the newly allocated
> mddev object directly with kfree() after kobject_init() is called
> in mddev_init().
> 
> Fix this by changing the kfree() call to a kobject_put().

I think the right answer is to only initialize the kobject just
before we add it.  I'll send an updated patch for that in a bit.



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux