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.