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] [thread-next>] [day] [month] [year] [list]
Message-ID: <52B31158.3030801@linux.com>
Date:	Thu, 19 Dec 2013 16:31:36 +0100
From:	Levente Kurusa <levex@...ux.com>
To:	Tejun Heo <tj@...nel.org>
CC:	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 21/38] workqueue: add missing put_device call

On 12/19/2013 04:20 PM, Tejun Heo wrote:
> Umm... this doesn't look right.  You're basically converting the code
> to the following,
> 
> 	x = kmalloc();
> 	if (register(x) < 0)
> 		put(x)
> 
> They're not symmetrical anymore.  register(), or any API call really,
> isn't supposed to have side effects which need explicit cleanup after
> a failure.  The fact that x is properly initialized even after
> register(x) failed is a coincidental implementation detail which
> shouldn't be depended upon.  Your patch is actively breaking the
> convention for no good reason.
> 
>  Nacked-by: Tejun Heo <tj@...nel.org>
> 
>>>From the patch title, I suppose you posted a bunch of patches towards
> this direction.  Please consider all of them nacked if they're doing
> the same thing.
> 
> Thanks.
> 

The reason I removed the kfree() was because the put_device() will decrement
wq_dev->dev's reference count to zero (it is set to one by device_register) and hence the
wq_device_release() will be called. Now, this effectively does the same the kfree() call
would have done but also driver core is notified.

Also, if you take a look at the comment for the device_register() function, it explicitly
says NOT to kfree the struct device, but instead call put_device() and let the device's release()
function take care.

-- 
Regards,
Levente Kurusa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ